4

我的目标是在加载应用程序后立即打开键盘。使用此代码,

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

在按钮上,我可以在按下按钮时加载键盘。但是,当放置在覆盖 onCreate() 部分时,什么也没有发生。

4

1 回答 1

8

将以下行添加到 AndroidManifest.xml 中的活动

android:windowSoftInputMode="stateVisible|adjustPan"
于 2011-01-19T21:46:56.917 回答