如何不让EditText不获得焦点
16lz
2021-01-26
一个activity页面中有两个元素:
1.Editext;
2.ListView
每次新进入页面后,Editext就会自动获得焦点。
请问如何不让Editext自动获得焦点?
在Edit的父view设置如下属性:
android:focusable="true"
android:focusableInTouchMode="true"
最简单的办法是在EditText前面放置一个看不到的LinearLayout,让它率先获取焦点:
- <LinearLayout
- android:focusable="true" android:focusableInTouchMode="true"
- android:layout_width="0px" android:layout_height="0px"/>
在manifest中,找到对应的Activity修改,加入这么一句android:windowSoftInputMode="stateHidden|adjustUnspecified"
例如:
- <activity
- android:name="qinXianYuZou.ZhiZuo.peizhi.Pei_Zhi"
- android:windowSoftInputMode="stateHidden|adjustUnspecified" >
- </activity>
在Edit的设置如下属性:
android:focusable="true"
android:focusableInTouchMode="true"
更多相关文章
- Android(安卓)Action Bar学习(一)--基本介绍及使用
- Android群英传之Android绘图机制与处理技巧
- 【转】Android.自定义控件的实现
- Android设置PreferenceCategory背景颜色的方法
- Android(安卓)ListView的多布局实现
- Android(安卓)Socket服务器 Servlet服务器
- android 1.6 launcher研究之修改worksapce上的屏数
- Android如何在app中通过一个按钮直接跳转到的系统的权限设置页面
- Android使用DataBinding实现MVVM模式(基本使用)