本文整理汇总了Java中android.view.inputmethod.InputMethodManager.toggleSoftInputFromWindow方法的典型用法代码示例。如果您正苦于以下问题:Java InputMethodManager.toggleSoftInputFromWindow方法的具体用法?Java InputMethodManager.toggleSoftInputFromWindow怎么用?Java InputMethodManager.toggleSoftInputFromWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.inputmethod.InputMethodManager
的用法示例。
在下文中一共展示了InputMethodManager.toggleSoftInputFromWindow方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editName
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@OnClick(R.id.editName)
protected void editName() {
animationAtStart();
InputMethodManager inputMethodManager =
(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(
mGridName.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED, 0);
mGridName.requestFocus();
mGridName.moveCursorToVisibleOffset();
mGridName.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
mGridSettingPresenter.setGridName(mGridName.getText().toString());
changeListener.nameChanged(String.valueOf(mGrid.getId()), mGridName.getText().toString());
animationAtEnd();
return true;
}
return false;
}
});
}
示例2: showKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* показать клавиатуру
*
* @param context - контекст
* @param view - view в фокусе, requestFocus которой запрашивается
*/
public static void showKeyboard(@Nullable Context context, @Nullable View view) {
if (context != null) {
if (view == null && context instanceof Activity) {
view = ((Activity) context).getCurrentFocus();
}
if (view == null) {
return;
}
view.requestFocus();
InputMethodManager inputMethodManager =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(view.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED,
0);
}
}
示例3: onClick
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.playPauseButton:
InputMethodManager inputMethodManager =
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(
relativeLayout.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED, 0);
if (isConnected && out!=null) {
new SendMessage().execute(Constants.PLAY);
}
break;
case R.id.nextButton:
if (isConnected && out!=null) {
new SendMessage().execute(Constants.NEXT);
}
break;
case R.id.previousButton:
if (isConnected && out!=null) {
new SendMessage().execute(Constants.PREVIOUS);
}
break;
}
}
示例4: showKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**显示/隐藏输入法
* @param context
* @param et
* @param toGetWindowTokenView(为null时toGetWindowTokenView = et) 包含et的父View,键盘根据toGetWindowTokenView的位置来弹出/隐藏
* @param show
*/
public static void showKeyboard(Context context, EditText et, View toGetWindowTokenView, boolean show){
if (context == null) {
Log.e(TAG, "showKeyboard context == null >> return;");
return;
}
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);//imm必须与context唯一对应
if (toGetWindowTokenView == null) {
Log.w(TAG, "showKeyboard toGetWindowTokenView == null");
toGetWindowTokenView = et;
}
if (toGetWindowTokenView == null) {
Log.e(TAG, "showKeyboard toGetWindowTokenView == null && et == null >> return;");
return;
}
if (show == false) {
imm.hideSoftInputFromWindow(toGetWindowTokenView.getWindowToken(), 0);
if (et != null) {
et.clearFocus();
}
} else {
if (et != null) {
et.setFocusable(true);
et.setFocusableInTouchMode(true);
et.requestFocus();
imm.toggleSoftInputFromWindow(toGetWindowTokenView.getWindowToken()
, InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
}
}
示例5: focusChange
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public void focusChange(View view) {
OTPEditText editText = (OTPEditText) view;
if (editText.getOrder() < getOtp().length() - 1) {
setFocus();
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.toggleSoftInputFromWindow(getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
}
}
}
示例6: showKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**显示/隐藏输入法
* @param context
* @param et
* @param toGetWindowTokenView(为null时toGetWindowTokenView = et) 包含et的父View,键盘根据toGetWindowTokenView的位置来弹出/隐藏
* @param show
*/
public static void showKeyboard(Context context, EditText et, View toGetWindowTokenView, boolean show){
if (context == null) {
Log.e(TAG, "showKeyboard context == null >> return;");
return;
}
imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);//imm必须与context唯一对应
if (toGetWindowTokenView == null) {
Log.w(TAG, "showKeyboard toGetWindowTokenView == null");
toGetWindowTokenView = et;
}
if (toGetWindowTokenView == null) {
Log.e(TAG, "showKeyboard toGetWindowTokenView == null && et == null >> return;");
return;
}
if (show == false) {
imm.hideSoftInputFromWindow(toGetWindowTokenView.getWindowToken(), 0);
if (et != null) {
et.clearFocus();
}
} else {
if (et != null) {
et.setFocusable(true);
et.setFocusableInTouchMode(true);
et.requestFocus();
imm.toggleSoftInputFromWindow(toGetWindowTokenView.getWindowToken()
, InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
}
}
示例7: onOptionsItemSelected
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case R.id.action_filter:
if (db.getList().size() != 0) {
actionDrawer();
}
return true;
case R.id.action_sort:
if (getPreferences(MODE_PRIVATE).getBoolean("isAlphabeticalOrder", false)) {
getPreferences(MODE_PRIVATE).edit().putBoolean("isAlphabeticalOrder", false).apply();
} else {
getPreferences(MODE_PRIVATE).edit().putBoolean("isAlphabeticalOrder", true).apply();
}
actionSort(true);
return true;
case R.id.action_changePassword:
changePassword();
return true;
case R.id.action_settings:
startActivity(new Intent(MainActivity.this, SettingsActivity.class));
return true;
case R.id.action_about:
AboutToast.getInstance().createAboutToast(getPackageManager(), getPackageName(), toast0, getApplicationContext());
return true;
case R.id.action_search:
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(listview.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
default:
return super.onOptionsItemSelected(item);
}
}
示例8: enableSoftInput
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public static void enableSoftInput(View view, boolean toEnable) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
if (toEnable) {
imm.toggleSoftInputFromWindow(view.getWindowToken(), InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS);
}
}
示例9: editSelectedTextEntity
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
private void editSelectedTextEntity() {
if (!(currentEntityView instanceof TextPaintView) || editingText) {
return;
}
curtainView.setVisibility(View.VISIBLE);
final TextPaintView textPaintView = (TextPaintView) currentEntityView;
initialText = textPaintView.getText();
editingText = true;
editedTextPosition = textPaintView.getPosition();
editedTextRotation = textPaintView.getRotation();
editedTextScale = textPaintView.getScale();
textPaintView.setPosition(centerPositionForEntity());
textPaintView.setRotation(0.0f);
textPaintView.setScale(1.0f);
undoItem.setVisibility(GONE);
doneItem.setVisibility(VISIBLE);
actionBar.setTitle(LocaleController.getString("PaintText", R.string.PaintText));
toolsView.setVisibility(GONE);
setColorPickerVisibilitySlide(false);
setTextDimVisibility(true, textPaintView);
textPaintView.beginEditing();
InputMethodManager inputMethodManager = (InputMethodManager) ApplicationLoader.applicationContext.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(textPaintView.getFocusedView().getWindowToken(), InputMethodManager.SHOW_FORCED, 0);
}
示例10: showKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* Shows the soft keyboard
*/
public static void showKeyboard(Activity activity) {
// Check if no view has focus:
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager inputMethodManager=(InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(view.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
}
}
示例11: openKeyBoard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* Open keyboard
*
* @param v with respect to this view
*/
public static void openKeyBoard(View v) {
try {
InputMethodManager inputMethodManager = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(v.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
} catch (Throwable e) {
//Not the end of the world. Keyborad didn't show up, that's it.
e.printStackTrace();
}
}
示例12: showSoftKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public static void showSoftKeyboard(Context context, View view) {
InputMethodManager inputMethodManager = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(view.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
}