How to automatically pop-up keyboard?
15,303
Solution 1
Use this code in the point where you want to display the keyboard (may be in oCreate?)
EditText myEditText = (EditText) findViewById(R.id.editPasswd);
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
.showSoftInput(myEditText, InputMethodManager.SHOW_FORCED);
Solution 2
I'm assuming you mean to automatically pop it up when the activity starts. If so, adding this to the activity
-tag in the manifest solved it for me (unlike Erfan's answer):
android:windowSoftInputMode="stateVisible"
Solution 3
One line in the Java class:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
Author by
Juronis
Updated on July 12, 2022Comments
-
Juronis almost 2 years
I have Edit Text field where I have to input a password, but I have to push this field. How to automatically pop-up keyboard without touching the Edit Text?
There is an Edit text xml field:
<EditText android:id="@+id/editPasswd" android:focusable="true" android:focusableInTouchMode="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="phone" android:password="true"/>
-
Juronis over 13 yearsthis worked for my: <activity android:name=".first" android:windowSoftInputMode="stateAlwaysVisible">