Show soft keyboard when Activity starts

I have 2 activities, A and B. When A starts, it checks for a condition and if true, it calls startActivityForResult() to start B. B only takes text input so it makes sense for the soft keyboard to automatically pop up when B start. When the activity starts, the EditText already has focus and it ready for input.

The problem is that the keyboard never shows up, even with windowSoftInputMode="stateAlwaysVisible" set in the manifest under the <activity> tag for B. I also tried with the value set to stateVisible . Since it doesn't show up automatically, I have to tap the EditText to make it show.

Anyone know what the solution might be?


What worked best for me is in Android Manifest for activity B adding

android:windowSoftInputMode="stateVisible"

Hope that helps for you as well.


Easiest solution: Put

android:windowSoftInputMode = "stateVisible" 

in Activity section of AndroidManifest.xml


If requestFocus on an EditText isn't showing it, maybe this'll do it:

InputMethodManager imm = (InputMethodManager)getSystemService(
    Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mEditText, 0);

Look here for more information.

链接地址: http://www.djcxy.com/p/93342.html

上一篇: Android键盘未显示

下一篇: 活动开始时显示软键盘