Why android InputMethodManager.showSoftInput() returns false?

為{幸葍}努か 提交于 2019-12-05 03:39:59
Jeroen Ost

This is a problem I ran into today as well. Of my 8 android devices only 1 has the problem and it's running Android 4.0.4.

The problem was fixed by adding

mEditText.requestFocus();
mEditText.requestFocusFromTouch();

before calling mEditText.showSoftInput(...)

You'll see the resultcode from showSoftInput is now true. I noticed that after the mEditText.requestFocus() the isFocused() was still false. Probably a bug in Android 4.0 and perhaps 4.1.

Please call showKeyboard after your mEditText is attached to window. Please make sure the time you make the call.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!