1、显示软键盘
public static void showSoftKeyboard(Activity activity)
{
InputMethodManager inputmethodmanager = (InputMethodManager)activity.getSystemService("input_method");
if(activity.getCurrentFocus() != null)
inputmethodmanager.showSoftInput(activity.getCurrentFocus(), 2);
inputmethodmanager.toggleSoftInput(0, 2);
}
2、隐藏软键盘
public static void hideSoftkeyboard(Activity activity)
{
if(activity != null && activity.getCurrentFocus() != null)
{
InputMethodManager inputmethodmanager = (InputMethodManager)activity.getSystemService("input_method");
if(inputmethodmanager != null)
inputmethodmanager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 2);
}
}
原创内容转载请保留出处GEEK笔记(https://www.geekapp.cn/)。