开发者

Show soft keyboard when Activity starts when no text field is present

开发者 https://www.devze.com 2023-01-09 21:38 出处:网络
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 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号