Question Detail

How to stop Auto get Focus Edittext in Activity android?

6 years ago Views 1648 Visit Post Reply

I am having a strange Problem. When I enter in Activity Automatically EditText get Focused and Keyboard got raise up. Only when a user clicks on EditText it will Focus otherwise not. How can we Control this?

Image result for auto focus edittext android


Thread Reply

Bili Greed

- 6 years ago

A good code sample is missing:

<!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
<LinearLayout
    android:focusable="true" 
    android:focusableInTouchMode="true"
    android:layout_width="0px" 
    android:layout_height="0px"/>

<!-- :nextFocusUp and :nextFocusLeft have been set to the id of this component
to prevent the dummy from receiving focus again -->
<AutoCompleteTextView android:id="@+id/userId_Autocomplete_ID"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:nextFocusUp="@id/userId_Autocomplete_ID" 
    android:nextFocusLeft="@id/userId_Autocomplete_ID"/>