how to open input Keyboard on load of activity

其实我在我的活动类中有一个EditText框。我想要的是,每当我的活动开始时它会自动打开输入键盘以及EditText.So如何完成。请任何人都提示我。


If you want to always show soft keyboard whenever your activity is started, the simplest way is to add this piece of code in your Android Manifest file:

<activity android:name=".YourActivity"
          android:windowSoftInputMode="stateAlwaysVisible" />

This will just work without you doing anything else with your code.


将这添加到你的清单文件中

<activity android:windowSoftInputMode="stateVisible|adjustResize" . . . >

这里是另一种方法: -

EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
链接地址: http://www.djcxy.com/p/93334.html

上一篇: Android KeyBoard不会显示在AlertDialog中

下一篇: 如何在活动负载上打开输入键盘