直播app系统源码,输入完内容后自动隐藏软键盘
直播app系统源码,输入完内容后自动隐藏软键盘实现的相关代码
//显示软键盘
public static void showKeyboard(final View view) {
if (view == null) return;
view.requestFocus();
InputMethodManager inputManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(view, 0);
}
//隐藏软键盘
public static void hideKeyboard(final View view) {
if (view == null) return;
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
//根据当前键盘状态切换,显示就隐藏,隐藏就显示
public static void toggleKeyboard(Context context) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, 0);
}
以上就是 直播app系统源码,输入完内容后自动隐藏软键盘实现的相关代码,更多内容欢迎关注之后的文章