【发布时间】:2018-03-11 07:42:16
【问题描述】:
我有一个Activity,只有一个EdtiText。当Activity 启动时,EditText 被聚焦并显示软键盘。这似乎发生在onResume 之后,因为当我以编程方式将键盘隐藏在onResume 中时,它不起作用。当我这样做时:
@Override
protected void onResume() {
super.onResume();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it.
//If no view currently has focus, create a new one, just so we can grab a window token from it
imm.hideSoftInputFromWindow(etBarcode.getWindowToken(), 0);
}
}, 500);
}
它会隐藏它(很快就会弹出)。
EditText 上是否有事件可以用来防止键盘弹出?或者其他阻止它显示的方法?
更新 focusableInTouchMode 没有做我想做的事,因为当设置为true 时,键盘会弹出,当设置为false 时,它根本无法聚焦。
【问题讨论】:
-
如果这些问题可以帮助stackoverflow.com/questions/1555109/…
标签: android android-softkeyboard