public static void hideSoftInput(Context context, View view) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
/**
* 显示软键盘
* @param context
* @param view
*/
public static void displaySoftInput(Context context, View view) {
if (context == null || view == null) {
return;
}
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(view, 0);
}
mEditTextAccount.postDelayed(new Runnable() {
@Override
public void run() {
Utils.displaySoftInput(UserLoginActivity.this, mEditTextAccount);
}
}, 300);