隐藏软键盘 显示软键盘
/**
* 隐藏软键盘
* @param activity
*/
public static void hideKeyboard(Activity activity) {
if (activity != null) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isActive()) {
imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}
}
}
/**
* 显示软键盘
* @param activity
*/
public static void showKeyboard(Activity activity) {
if (activity != null) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (!imm.isActive()) {
imm.showSoftInputFromInputMethod(activity.getCurrentFocus().getWindowToken(), 0);
}
}
}
一行代码实现Android软键盘与EditText的交互
http://mp.weixin.qq.com/s/q-kEr_4JWT-LKIXaXskIoA