I want to open soft keyboard while starting an activity.
The activity contains nothing as its element. I just need to open soft keyboard o开发者_StackOverflow社区n the launch.
I've tried with
<activity android:windowSoftInputMode="stateAlwaysVisible|stateVisible|adjustResize"
but it didn't work.
Also tried with
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
but it didn't work as well
i'm using emulator to run the code
Thanks in advance
Have you tried
<activity
android:windowSoftInputMode="stateVisible|adjustPan">
?
HI,
you could try :
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(flags, InputMethodManager.SHOW_IMPLICIT);
This will not open the keyboard if there is a physical one available and opened.(flags can be 0 if there is nothing.)
try the below code hope it helps
<activity android:windowSoftInputMode="adjustPan">
for more information regarding this Read
精彩评论