手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android取消EditText自动获取焦点默认行为
Android取消EditText自动获取焦点默认行为
摘要:在项目中,一进入一个页面,EditText默认就会自动获取焦点。那么如何取消这个默认行为呢?在网上找了好久,有点监听软键盘事件,有点调用cl...

在项目中,一进入一个页面, 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>

【Android取消EditText自动获取焦点默认行为】相关文章:

Android 开发环境配置问题

Android定制RadioButton样式三种实现方法

Android按键添加和处理的三个解决

android开发中ListView与Adapter使用要点介绍

Android控件系列之CheckBox使用介绍

android 搜索自动匹配关键字并且标红

Android自定义图片质量的控件截图类代码

Android模拟器中窗口截图存成文件实现思路及代码

Android读取对应的键值

Android自动禁用布局里的所有子控件

精品推荐
分类导航