I want the EditText in my application to have the cursor by default when the application starts. I tried using
<EditText
android:id="@+id/idInput"
android:layout_width="480dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:ems="10" >
<requestFocus />
</EditText>
and also
userIdInput = (EditText)findViewById(R.id.idInput);
userIdInput.setFocusable(true);
userIdInput.setFocusableInTouchMode(true);
userIdInput.requestFocus();
But none of it seems to have any effect. The cursor is nowhere visible when the application starts and I have to manually click the EditText to make the cursor appear on it.
Where could I be possibly go wrong ?
By the way, I am developing for Android 4.0.3 tablets.
Try this
userIdInput = (EditText)findViewById(R.id.idInput);
userIdInput.post(new Runnable()
{
public void run()
{
userIdInput .requestFocus();
}
});
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