Reputation: 3936
I have an issue when the activity starts, android automatically places focus on the first edittext. How do I prevent android from doing that?
Upvotes: 10
Views: 23411
Reputation: 34390
Three ways to solve this..
Set these attributes to the parent..
And now, when activity starts this layout getting default focus.
Also we can remove focus from children views in runtime (e.g. after finishing child editing):
findViewById(R.id.mainLayout).requestFocus(); or
Look in the AndroidManifest.xml element.
android:windowSoftInputMode="stateHidden"
It always hide key board when entering the activity.
Upvotes: 1
Reputation: 14025
Have a look here
Or you could just hide the keyboard, focus remains on the EditText upon starting the activity:
android:windowSoftInputMode="stateHidden"
Upvotes: 15
Reputation: 1631
use setFocusable (boolean focusable) to prevent. http://developer.android.com/reference/android/view/View.html#setFocusable(boolean)
Upvotes: 1