EditText has focus when Activity starts, but soft keyboard is not shown

as mentioned above, the keyboard does not show up, although the EditText is focused (orange border) and the cursor is blinking. When I click into text field, it opens up, however I want it to be open right when the activity starts.

I tried setting android:windowSoftInputMode="stateVisible" in the activity, I tried showSoftInput(yourTextBox, InputMethodManager.SHOW_IMPLICIT); and also requestFocus() . But no success...

What could be the problem?


Try something like this:

 EditText myEditText = (EditText) findViewById(R.id.editPasswd);

((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
    .showSoftInput(myEditText, InputMethodManager.SHOW_FORCED);

Are you testing on emulator? If you do, you should know that keyboard doesn't pop up on emulator :), but it does on a real device

Good luck, Arkde


在创建活动时显示键盘的另一种方式是将此代码添加到您的AndroidManifest文件中,以便在开始时显示键盘的活动:

<activity android:name=".UserLogin" android:windowSoftInputMode="stateAlwaysVisible"/>
链接地址: http://www.djcxy.com/p/24196.html

上一篇: 使editText失去对新闻的关注

下一篇: 活动开始时EditText具有焦点,但不显示软键盘