zoukankan      html  css  js  c++  java
  • Android中使EditText失去焦点

    在我们的应用中,有时候一进入一个页面, EditText默认就会自动获取焦点。弹出输入法框,用户体验很不好,

    那么如何取消这个默认行为呢?

    在网上找了好久,有点监听软键盘事件的方法,有调用 clearFouse()方法,但是测试了都不行!在对应的 xml中也找不到相应的属性可以关闭这个默认行为。

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

    android:focusable="true"   
    android:focusableInTouchMode="true"

     转:http://bbs.9ria.com/thread-236141-1-1.html

    <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> 

  • 相关阅读:
    书籍阴影
    Cookie工具类
    兼容性问题总结
    pc端弹框
    懒加载 js----例子------图片
    pc端样式初始化
    Sublime 插件- px 转rem
    手机端1px细线公共类
    移动端样式初始化
    SQL Server(七)——存储过程
  • 原文地址:https://www.cnblogs.com/wsfjlagr/p/3455079.html
Copyright © 2011-2022 走看看