【发布时间】:2023-04-03 13:21:01
【问题描述】:
我有一个基于 webview 的应用程序,当我将焦点放在某些输入上时,我希望在其中打开相应的键盘。使用我在下面提供的代码,它会打开,但即使对于数字类型输入,它也总是会打开 qwerty 键盘。
private void ShowKeyboard(final boolean show) {
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (show) {
InputMethodManager mgr = (InputMethodManager) General.MainShellReference.getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(General.appView, InputMethodManager.SHOW_IMPLICIT);
((InputMethodManager) General.MainShellReference.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(General.appView, 0);
} else {
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
}
});
} catch (Exception ex) {
;
}
}
【问题讨论】:
标签: android android-webview android-softkeyboard android-keypad