如何不让EditText不获得焦点

一个activity页面中有两个元素:
1.Editext;
2.ListView

每次新进入页面后,Editext就会自动获得焦点。

请问如何不让Editext自动获得焦点?


在Edit的父view设置如下属性:
android:focusable="true"
android:focusableInTouchMode="true"


最简单的办法是在EditText前面放置一个看不到的LinearLayout,让它率先获取焦点:

          
          
          
          
  1. <LinearLayout
  2.         android:focusable="true" android:focusableInTouchMode="true"
  3.         android:layout_width="0px" android:layout_height="0px"/>

在manifest中,找到对应的Activity修改,加入这么一句android:windowSoftInputMode="stateHidden|adjustUnspecified"
例如:

           
           
           
           
  1. <activity
  2.             android:name="qinXianYuZou.ZhiZuo.peizhi.Pei_Zhi"
  3.             android:windowSoftInputMode="stateHidden|adjustUnspecified" >
  4.         </activity>


在Edit的设置如下属性:
android:focusable="true"
android:focusableInTouchMode="true"


你可能感兴趣的:(如何不让EditText不获得焦点)