一个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"


更多相关文章

  1. Android(安卓)Action Bar学习(一)--基本介绍及使用
  2. Android群英传之Android绘图机制与处理技巧
  3. 【转】Android.自定义控件的实现
  4. Android设置PreferenceCategory背景颜色的方法
  5. Android(安卓)ListView的多布局实现
  6. Android(安卓)Socket服务器 Servlet服务器
  7. android 1.6 launcher研究之修改worksapce上的屏数
  8. Android如何在app中通过一个按钮直接跳转到的系统的权限设置页面
  9. Android使用DataBinding实现MVVM模式(基本使用)

随机推荐

  1. Android(安卓)Multiple dex files define
  2. android shareperfence的存储更改与读取
  3. android出现段错误时的查找定位的方法
  4. 如何把你的安卓手机变成Linux?
  5. SoLoader,android动态加载so库
  6. Android(安卓)之怎么删除eclipse自动生成
  7. ListView中添加Button后,Button的点击事件
  8. Android Stduio 发生 Process 'command '
  9. Android 微信/支付宝 h5调原生支付
  10. android中的Bitmap