六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 621|回复: 0

Android中使EditText失去焦点[图]

[复制链接]
 楼主| 发表于 2013-9-22 22:09:52 | 显示全部楼层 |阅读模式
        安卓如何获得焦点的方法下面小编就来告诉大家!
        在我们的应用中,有时候一进入一个页面, EditText默认就会自动获取焦点。弹出输入法框,用户体验很不好,
        那么如何取消这个默认行为呢?
        在网上找了好久,有点监听软键盘事件的方法,有调用 clearFouse()方法,但是测试了都不行!在对应的 xml中也找不到相应的属性可以关闭这个默认行为。
        后来研究了一下,在其父控件下,添加如下的属性,就可以完美解决:
        android:focusable="true"   
android:focusableInTouchMode="true"
        举例如下:
[url=][/url] <LinearLayout         android:layout_width="fill_parent"android:layout_height="wrap_content"androidrientation="horizontal"android:focusable="true"android:focusableInTouchMode="true"        >                <EditText             android:id="@+id/et_enter_msg_content"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="1"            />                <Button             android:id="@+id/sent"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/send"            />                    </LinearLayout>希望有帮到你~
本文摘自:http://www.vipcn.com/chengxukaifa/ruanjiangongcheng/380533.html

该会员没有填写今日想说内容.
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表