EditTextを自動的にフォーカスを取得できません.

5300 ワード

  :http://blog.csdn.net/subaohao/article/details/9043895

 activity    1  1    EditText,   activity      EditText     ,        EditText         ,     ?
 
 
    EditText      LinearLayout,           ,    。            LinearLayout,         
 <requestFocus />  ,               。
<LinearLayout
        android:focusable="true" android:focusableInTouchMode="true"
        android:layout_width="0px" android:layout_height="0px">
        <requestFocus />
    </LinearLayout>
  ,   EditText,        <requestFocus />。
 
 
    ,    ,  
EditText clearFocus(), :
   EditText textIn = (EditText)findViewById(R.id.TextInput);
    textIn.clearFocus();
    textIn.setSelected(false);
  ,     。


Android EditText

, , EditText 。

 

,   ,   clearFouse() , ! xml

 

: EditText ,

   android:focusable="true"      android:focusableInTouchMode="true"

, EditText !

 

 

<LinearLayout          style="@style/FillWrapWidgetStyle"         android:orientation="vertical"         android:background="@color/black"         android:gravity="center_horizontal"                  android:focusable="true"           android:focusableInTouchMode="true"         >         <ImageView             android:id="@+id/logo"             style="@style/WrapContentWidgetStyle"             android:background="@drawable/dream_dictionary_logo"           />         <RelativeLayout              style="@style/FillWrapWidgetStyle"             android:background="@drawable/searchbar_bg"             android:gravity="center_vertical"             >             <EditText                 android:id="@+id/searchEditText"                style="@style/WrapContentWidgetStyle"                android:background="@null"                android:hint="Search"                android:layout_marginLeft="40dp"                android:singleLine="true"              />                      </RelativeLayout>              </LinearLayout>