Android starts the Activity and prevents EditText from Automatically Obtaining the focus. androidedittext
This problem is a hot issue in StackOverFlow. Stop EditText from gaining focus at Activity startup. Now I will translate this question and sort out the answers to ensure that this problem can be solved.
The author encountered the following problems:
I have an Activity with an EditText and a ListView. When I start the Activity, EditText automatically obtains the focus (the cursor is flashing ). But I don't want him to get the focus. I tried the following statement:
EditText. setSelected (false );
But it does not work at all. How can I prevent EditText from getting the focus itself?
Summary:
Answer 1: Make sure that the requestFocus label is not found in your xml layout file. This label will be automatically added by eclipse. If so, delete it.
Answer 2: Add two rows in the parent layout of EditText.
<LinearLayout android: focusable = "true" android: focusableInTouchMode = "true"/>
In this way, the parent layout gets the focus by default, and the focus is snatched from EditText.
Answer 3: No Answer 3. The above two answers can basically solve the problem.