2016-10-23 4 views
0

enter image description hereAndroid entfernen EditText Auswahl

I 2 editText s haben, whenewer ich app starten zuerst (orange) Bearbeiten von Text wird automatisch ausgewählt zu werden.

Ich versuchte klaren Fokus, aber das hatte nicht für mich gearbeitet.

   <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 
        <android.support.design.widget.TextInputLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content"> 
         <EditText 
          android:id="@+id/event_title" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:inputType="textPersonName" 
          android:hint="@string/edit_text_title" /> 
        </android.support.design.widget.TextInputLayout> 
        <android.support.design.widget.TextInputLayout 
         android:id="@+id/txtInputLayoutPassword" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content"> 
         <EditText 
          android:id="@+id/event_description" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:inputType="textMultiLine" 
          android:hint="@string/edit_text_description" /> 
        </android.support.design.widget.TextInputLayout> 
       </LinearLayout> 

Wie zuerst bearbeiten Text wie zweite aussehen lassen?

+0

Manchmal Fokus Clearing ist nicht genug, weil das System (Android) nicht weiß, wer um den Fokus zu geben. Nimm das Eltern-Layout 'LinearLayout' und rufe 'requestFocus()' in dieser Ansicht auf, nachdem du 'clearFocus()' auf 'EditText' aufgerufen hast. –

Antwort

1
    <LinearLayout 
        style="@style/Widget.CardContent" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"> 


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

        <android.support.design.widget.TextInputLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content"> 
         <EditText 
          android:id="@+id/event_title" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:inputType="textPersonName" 
          android:hint="@string/edit_text_title" /> 
        </android.support.design.widget.TextInputLayout> 
        <android.support.design.widget.TextInputLayout 
         android:id="@+id/txtInputLayoutPassword" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content"> 
         <EditText 
          android:id="@+id/event_description" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:layout_gravity="center" 
          android:inputType="textMultiLine" 
          android:hint="@string/edit_text_description" /> 
        </android.support.design.widget.TextInputLayout> 
       </LinearLayout> 
+0

Dieser hat funktioniert :) – armandasalmd

0

Die ViewGroup im Berührungsmodus fokussierbar machen. Wie dies aus dem Code:

<LinearLayout 
    style="@style/Widget.CardContent" 
    android:focusableInTouchMode="true" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
+0

Arbeite nicht, vielleicht weil ich das in der unteren Seite verwende, die ich vorher aufgerufen habe ? Dann würde ich Codezeile benötigen, um es abzuwählen. – armandasalmd