您的位置:首页 > 移动开发 > Android开发

Android中使EditText失去焦点,edittext禁止弹出键盘

2015-05-20 10:33 483 查看
第一种方法:.在网上找了好久,有点监听软键盘事件的方法,有调用 clearFouse()方法,但是测试了都不行!在对应的 xml中也找不到相应的属性可以关闭这个默认行为。

后来研究了一下,在其父控件下,添加如下的属性,就可以完美解决:

android:focusable="true"  

android:focusableInTouchMode="true"

举例如下:

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="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>


第二种方法:直接关闭输入法

?
 调用这个方法体就行了,具体if语句里面的几个参数,我就借用一个网友的日志来写把(在此感谢)

?
 好了,祝大家玩的开心
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息