I have an Activity
in Android, with two elements:
EditText
ListView
When my Activity
starts, the EditText
immediately has input focus (flashing cursor). I don't want any control to have input focus at startup. I tried:
EditText.setSelected(false);
No luck. How can I convince the EditText
to not select itself when the Activity
starts?
using the information provided by other posters, I used the following solution:
in the layout XML
in onCreate()
and finally, in onResume()
Add
android:windowSoftInputMode="stateAlwaysHidden"
in the activity tag of theManifest.xml
file.Source
Yeah I did the same thing - create a 'dummy' linear layout which gets initial focus. Furthermore, I set the 'next' focus IDs so the user can't focus it any more after scrolling once:
a lot of work just to get rid of focus on a view..
Thanks
You can achieve this by creating a dummy
EditText
with layout width and height set to0dp
, and request focus to that view. Add the following code snippet in your xml layout:The only solution I've found is:
android:focusable="true"
andandroid:focusableInTouchMode="true"
And the
EditText
won't get the focus after starting the activity