本文整理汇总了Java中android.view.inputmethod.InputMethodManager.hideSoftInputFromWindow方法的典型用法代码示例。如果您正苦于以下问题:Java InputMethodManager.hideSoftInputFromWindow方法的具体用法?Java InputMethodManager.hideSoftInputFromWindow怎么用?Java InputMethodManager.hideSoftInputFromWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.inputmethod.InputMethodManager
的用法示例。
在下文中一共展示了InputMethodManager.hideSoftInputFromWindow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hideSoftKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public static void hideSoftKeyboard(View view) {
if (view == null) {
return;
}
View mFocusView = view;
Context context = view.getContext();
if (context != null && context instanceof Activity) {
Activity activity = ((Activity) context);
mFocusView = activity.getCurrentFocus();
}
if (mFocusView == null) {
return;
}
mFocusView.clearFocus();
InputMethodManager manager = (InputMethodManager) mFocusView.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
manager.hideSoftInputFromWindow(mFocusView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
示例2: showSoftKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* Shows/ hides soft input (soft keyboard).
*
* @param view
* {@link View}.
* @param show
* {@code true} or {@code false}. If {@code true}, this method
* will use a {@link Runnable} to show the IMM. So you don't need
* to use it, and consider using
* {@link View#removeCallbacks(Runnable)} if you want to cancel.
*/
public static void showSoftKeyboard(final View view, final boolean show) {
final InputMethodManager imm = (InputMethodManager) view.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null)
return;
if (show) {
view.post(new Runnable() {
@Override
public void run() {
imm.showSoftInput(view, 0, null);
}// run()
});
} else
imm.hideSoftInputFromWindow(view.getWindowToken(), 0, null);
}
示例3: onEditorAction
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
if (null == getActivity()) return false;
FragmentTransaction transactionPhoto = getChildFragmentManager().beginTransaction();
FragmentTransaction transactionCollection = getChildFragmentManager().beginTransaction();
FragmentTransaction transactionUser = getChildFragmentManager().beginTransaction();
String text = textView.getText().toString().trim();
if (!TextUtils.isEmpty(text)) {
transactionPhoto.replace(R.id.search_photo_container, SearchPhotoFragment.newInstance(text)).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commitAllowingStateLoss();
transactionCollection.replace(R.id.search_collection_container, SearchCollectionFragment.newInstance(text)).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commitAllowingStateLoss();
transactionUser.replace(R.id.search_user_container, SearchUserFragment.newInstance(text)).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commitAllowingStateLoss();
}
View view = getActivity().getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
return true;
}
示例4: dispatchTouchEvent
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
View v = getCurrentFocus();
boolean ret = super.dispatchTouchEvent(event);
if (v instanceof AutoCompleteTextView) {
View currentFocus = getCurrentFocus();
int screenCoords[] = new int[2];
currentFocus.getLocationOnScreen(screenCoords);
float x = event.getRawX() + currentFocus.getLeft() - screenCoords[0];
float y = event.getRawY() + currentFocus.getTop() - screenCoords[1];
if (event.getAction() == MotionEvent.ACTION_UP
&& (x < currentFocus.getLeft() ||
x >= currentFocus.getRight() ||
y < currentFocus.getTop() ||
y > currentFocus.getBottom())) {
InputMethodManager imm =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);
v.clearFocus();
}
}
return ret;
}
示例5: hideSoftKeybord
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* 隐藏软键盘
*
* @param activity
*/
public static void hideSoftKeybord(Activity activity) {
if (null == activity) {
return;
}
try {
final View v = activity.getWindow().peekDecorView();
if (v != null && v.getWindowToken() != null) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
} catch (Exception e) {
}
}
示例6: sendClick
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@OnClick(R.id.send_wish)
public void sendClick(View v) {
String author = authorOfWish.getText().toString();
String wish = wishText.getText().toString();
if (canSendWish()) {
if (!TextUtils.isEmpty(author) && !TextUtils.isEmpty(wish) && !(spinner.getSelectedItemPosition() == 0)) {
addWishToCloud(wish, author, spinner.getSelectedItem().toString());
Toast.makeText(this, wishSent, Toast.LENGTH_SHORT).show();
View view = this.getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
mLayout.setPanelState(PanelState.COLLAPSED);
} else {
Toast.makeText(this, fillTextView, Toast.LENGTH_SHORT).show();
}
} else {
showAlertToMakeWish();
}
}
示例7: onKey
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
switch (arg1) {
case KeyEvent.KEYCODE_ENTER:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
searchTheWeb(mSearch.getText().toString());
LightningView v=getCurrentWebView();
if (v != null) {
v.requestFocus();
}
return true;
default:
break;
}
return false;
}
示例8: 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);
}
示例9: onTouch
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
@SuppressLint("ClickableViewAccessibility")
public boolean onTouch(View v, MotionEvent event) {
if (v instanceof Spinner) {
InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
return false;
}
示例10: hideSoftKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* hide input method.
*/
public void hideSoftKeyboard(View view) {
if (view == null) {
return;
}
InputMethodManager inputMethodManager = (InputMethodManager) mActionBarActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
IBinder localIBinder = view.getWindowToken();
if (localIBinder != null)
inputMethodManager.hideSoftInputFromWindow(localIBinder, 0);
}
}
示例11: hideKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
static public void hideKeyboard(Activity act) {
if (act == null) return;
if (act.getCurrentFocus() == null) {
act.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
} else {
InputMethodManager imm = (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow((null == act.getCurrentFocus()) ? null : act.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
示例12: hideKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* 隐藏软键盘
*
* @param view 用来绑定隐藏键盘的View
*/
public static void hideKeyboard(Context context, View view) {
if (null != context && null != view) {
InputMethodManager imm = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
示例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: closeKeyBoard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
private void closeKeyBoard() throws NullPointerException {
// Central system API to the overall input method framework (IMF) architecture
InputMethodManager inputManager =
(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// Base interface for a remotable object
IBinder windowToken = getCurrentFocus().getWindowToken();
// Hide type
int hideType = InputMethodManager.HIDE_NOT_ALWAYS;
// Hide the KeyBoard
inputManager.hideSoftInputFromWindow(windowToken, hideType);
}
示例15: hideSoftKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public static void hideSoftKeyboard(@NonNull AppCompatActivity activity) {
if (activity != null && activity.getCurrentFocus() != null) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}
}