Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get keyboard to load onCreate()

My aim is to get the keyboard to open as soon as the app is loaded. Using this code,

InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                  inputMgr.toggleSoftInput(0, 0);`

on a button, I can get the keyboard to load when the button is pressed. However, when placed in the override onCreate() section, nothing happens.

like image 976
Jez Fischer Avatar asked Feb 25 '23 08:02

Jez Fischer


1 Answers

Add the following line to the activity in AndroidManifest.xml

android:windowSoftInputMode="stateVisible|adjustPan"
like image 118
Jez Fischer Avatar answered Mar 07 '23 18:03

Jez Fischer