本文整理汇总了Java中android.view.inputmethod.InputMethodManager类的典型用法代码示例。如果您正苦于以下问题:Java InputMethodManager类的具体用法?Java InputMethodManager怎么用?Java InputMethodManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputMethodManager类属于android.view.inputmethod包,在下文中一共展示了InputMethodManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEditorAction
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (EditorInfo.IME_ACTION_DONE == actionId) {
if (mEditText.getText().toString().isEmpty())
{
SuperToast toast = chatSDKUiHelper.getAlertToast();
toast.setGravity(Gravity.TOP, 0, 0);
toast.setText("Please enter chat name");
toast.show();
return true;
}
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
// Return input text to activity
listener.onFinished(mEditText.getText().toString());
this.dismiss();
return true;
}
return false;
}
示例2: run
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
@Override
public void run() {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w, h + HEIGHT_PADDING);
params.leftMargin = x;
params.topMargin = y;
if (mTextEdit == null) {
mTextEdit = new DummyEdit(getContext());
mLayout.addView(mTextEdit, params);
} else {
mTextEdit.setLayoutParams(params);
}
mTextEdit.setVisibility(View.VISIBLE);
mTextEdit.requestFocus();
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mTextEdit, 0);
mScreenKeyboardShown = true;
}
示例3: hideKeyboard
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
public static void hideKeyboard(@NonNull Activity activity) {
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
示例4: onFocusChanged
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
@Override
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
if (mFocusAnim != null) {
mFocusAnim.end();
}
if (gainFocus) {
mFocusAnim = ObjectAnimator.ofFloat(this, "FocusLine", mFocusLineLength, (float) (getWidth() - 2 * mRoundRadius));
input.showSoftInput(this, InputMethodManager.SHOW_FORCED);
} else {
mFocusAnim = ObjectAnimator.ofFloat(this, "FocusLine", mFocusLineLength, 0);
input.hideSoftInputFromInputMethod(this.getWindowToken(), 0);
}
mFocusAnim.setDuration(1000).setInterpolator(new OvershootInterpolator());
mFocusAnim.start();
}
示例5: hideKeyboard
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
/**
* Hides the soft keyboard from screen
*
* @param view Usually the EditText, but in dynamically layouts you should pass the layout
* instead of the EditText
* @return true, if keyboard has been hidden, otherwise false (i.e. the keyboard was not displayed
* on the screen or no Softkeyboard because device has hardware keyboard)
*/
public static boolean hideKeyboard(View view) {
if (view == null) {
throw new NullPointerException("View is null!");
}
try {
InputMethodManager imm =
(InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) {
return false;
}
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
} catch (Exception e) {
return false;
}
return true;
}
示例6: showSoftKeyboard
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
public void showSoftKeyboard() {
if (isKeyboardOpen()) return;
if (ui.emojiDrawer.isShowing()) {
postOnKeyboardOpen(new Runnable() {
@Override
public void run() {
hideEmojiDrawer();
}
});
}
ui.editText.post(new Runnable() {
@Override
public void run() {
ui.editText.requestFocus();
InputMethodManager imm =
(InputMethodManager) getContext()
.getSystemService(INPUT_METHOD_SERVICE);
imm.showSoftInput(ui.editText, SHOW_IMPLICIT);
}
});
}
示例7: onCreate
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
/**
* Main initialization of the input method component. Be sure to call
* to super class.
*/
@Override public void onCreate() {
super.onCreate();
mInputMethodManager = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
mWordSeparators = getResources().getString(R.string.word_separators);
mSuggestions = EMPTY_LIST;
mQuranSuggestions = EMPTY_MLIST;
mSavedPreSpaces = 0;
try {
mQuranSearch = new QuranSearch(this);
} catch (IOException |SecurityException e) {
mQuranSearch = null;
Toast.makeText(this, "Quran Search disabled, File not found!", Toast.LENGTH_LONG).show();
// TODO disable/gray the Moshaf/shift key & disable/grey Prefs
if (DEBUG) e.printStackTrace();
}
if (mQuranSearch != null) {
PreferenceManager.setDefaultValues(this, R.xml.ime_preferences, false);
setUthmaniTypeFace(Typeface.createFromAsset(getAssets(), "UthmanicHafs.otf"));
}
}
示例8: setCancelAction
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
private void setCancelAction(Button cancelButton, final EditText dateEditText,
final EditText timeEditText, final TextInputLayout... textInputLayouts) {
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
for (TextInputLayout textInputLayout : textInputLayouts) {
textInputLayout.getEditText().setText("");
textInputLayout.clearFocus();
// Hide the keyboard
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(textInputLayout.getEditText().getWindowToken(), 0);
}
dateEditText.setText("");
timeEditText.setText("");
}
});
}
示例9: setKeypadVisibility
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
public static void setKeypadVisibility(Context context, EditText inputNote, int visibility) {
InputMethodManager imm = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
switch (visibility) {
case View.VISIBLE:
// 開啟鍵盤
imm.showSoftInput(inputNote, InputMethodManager.SHOW_IMPLICIT);
break;
case View.GONE:
case View.INVISIBLE:
// 關閉鍵盤
imm.hideSoftInputFromWindow(inputNote.getWindowToken(), 0);
break;
} /* end of switch */
}
示例10: showSoftInputFromWindow
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
/**
* EditText获取焦点并显示软键盘
*/
public void showSoftInputFromWindow(EditText editText) {
//添加文字edittext弹出软键盘
editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
InputMethodManager imm = (InputMethodManager) PostActivity.this
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
}
}, 100);//这里的时间大概是自己测试的
}
示例11: showKeyboard
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
public void showKeyboard(View view) {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1 && view.hasFocus()) {
view.clearFocus();
}
view.requestFocus();
InputMethodManager imm = (InputMethodManager) view.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.showSoftInput(view, 0);
}
}
示例12: switchToNextInputMethodAndSubtype
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
private boolean switchToNextInputMethodAndSubtype(final IBinder token) {
final InputMethodManager imm = mImmWrapper.mImm;
final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList();
final int currentIndex = getImiIndexInList(getInputMethodInfoOfThisIme(), enabledImis);
if (currentIndex == INDEX_NOT_FOUND) {
Log.w(TAG, "Can't find current IME in enabled IMEs: IME package="
+ getInputMethodInfoOfThisIme().getPackageName());
return false;
}
final InputMethodInfo nextImi = getNextNonAuxiliaryIme(currentIndex, enabledImis);
final List<InputMethodSubtype> enabledSubtypes = getEnabledInputMethodSubtypeList(nextImi,
true /* allowsImplicitlySelectedSubtypes */);
if (enabledSubtypes.isEmpty()) {
// The next IME has no subtype.
imm.setInputMethod(token, nextImi.getId());
return true;
}
final InputMethodSubtype firstSubtype = enabledSubtypes.get(0);
imm.setInputMethodAndSubtype(token, nextImi.getId(), firstSubtype);
return true;
}
示例13: closeKeyBoard
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
private void closeKeyBoard() throws NullPointerException {
InputMethodManager inputManager =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
IBinder windowToken = getCurrentFocus().getWindowToken();
int hideType = InputMethodManager.HIDE_NOT_ALWAYS;
inputManager.hideSoftInputFromWindow(windowToken, hideType);
}
示例14: HideSoftInput
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
private void HideSoftInput(IBinder token) {
if (token != null) {
InputMethodManager manager = (InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE);
manager.hideSoftInputFromWindow(token,
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
示例15: performAdd
import android.view.inputmethod.InputMethodManager; //导入依赖的package包/类
private void performAdd() {
InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editUrl.getWindowToken(), 0);
showDialog();
final Map<String, Object> params = new ArrayMap<String, Object>();
params.put(Constants.PREFS_USER, editLogin.getText().toString());
params.put(Constants.PREFS_PASSWORD, editPass.getText().toString());
Communicator.getInstance().login(params,
collectUrl(editUrl.getText().toString()), this);
}