I have 2 EditTexts in the MainActivity Layout. If i run the application normally the 1st EditText gets focused but the softkeyboard is not openned.
but when i used this:
public class TestingActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
EditText et1 = (EditText) findViewById(R.id.editText1);
EditText et2 = (EditText) findViewById(R.id.editText2);
et2.requestFocus();
InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mInputMethodManager.showSoftInput(et2, InputMethodManager.SHOW_IMPLICIT);
}
}
expecting the 2nd EditText will get focus and softkeyboard will be openned.
I only get focus, but the softkeyboard is openned only when i click on the EditText.
Thank You
To enable your latest Android keyboard, scroll to the bottom and hit the System entry. Then, click Languages & input. Pick Virtual keyboard on the following page. You will find a list of all the existing keyboards on your smartphone here.
Simple. Download the Gboard - the Google Keyboard – Apps on Google Play - and then go to the settings section on your Android device >> General Management >> Language and Input >> Default Keyboard (Select Gboard).
Navigate to and open Settings, and then scroll and tap Apps. Tap the sort icon and then tap the switch next to Show system apps, and then tap OK. Search for or scroll to Samsung Keyboard, and then tap it.
Under Settings > click on the “Language and Input” option. This option may be available under “System” in some phones. After you click on the “Language and Input” option, click on “Virtual Keyboard” or in “Current Keyboard”.
Try specifying the android:windowSoftInputMode attribute in your AndroidManifest.xml
file for your activity.
For example:
<activity android:name=".TestingActivity" android:windowSoftInputMode="stateVisible|adjustResize" />
You probably don't need any of the code that uses InputMethodManager
in your Activity.
I notice that one reason for the keyboard not showing up is selecting an inputtype not supported by the specific Android device. For instance InputType.TYPE_NUMBER_VARIATION_NORMAL will not work on my Asus Transformer (no keyboard shows up), while InputType.TYPE_CLASS_NUMBER will work just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With