Reputation: 2037
I'd like that when I start an activity my edit text open keyboard automatically
I'm using this code
<EditText
android:id="@+id/add_account_et_name"
android:layout_width="match_parent"
android:layout_height="@dimen/component_height"
android:background="@android:color/transparent"
android:ellipsize="start"
android:ems="10"
android:gravity="center"
android:hint="@string/account_name"
android:inputType="textCapWords"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearance" >
<requestFocus />
</EditText>
It's not working!!
I'm using the same edittext in another activity and it's working! Why??? Anybody can help me?
Upvotes: 0
Views: 1435
Reputation: 51411
In your manifest file, try adding the following to the activity that you want to show the keyboard when the activity starts:
<activity android:windowSoftInputMode="stateVisible" ... />
Another way:
EditText et = (EditText) findViewById(R.id.yourEditText);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT);
Upvotes: 2