关于android:focusable属性 - daishuguang
来源:互联网 发布:人工智能工程师 编辑:程序博客网 时间:2024/06/05 20:10
原文 http://www.cnblogs.com/daishuguang/p/3851830.html
在项目中,一进入一个页面, EditText默认就会自动获取焦点。
那么如何取消这个默认行为呢?
解决之道:在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>
来自:http://blog.csdn.net/woshicaixianfeng/article/details/7261718 灰常感谢这位同学。。。
还有一个方法也可以非常简单的实现这个功能:
EditText对象的clearFocus();
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editMsgView.getWindowToken(), 0);(关闭软键盘。。。)
- 关于android:focusable属性 - daishuguang
- 关于android:focusable属性 - daishuguang
- 关于android:focusable属性
- Android开发中的View类的视图属性focusableInTouchMode这个属性跟focusable有什么区别?
- Android开发中的View类的视图属性focusableInTouchMode这个属性跟focusable有什么区别?
- Android开发中的View类的视图属性focusableInTouchMode这个属性跟focusable有什么区别?
- Android中focusable属性的妙用——底层按钮的实现
- Android中focusable属性的妙用——底层按钮的实现
- Android中focusable属性的妙用——底层按钮的实现
- Android中focusable属性的妙用之底层按钮的实现
- Android中focusable属性的妙用之底层按钮的实现
- Android中focusable属性的妙用——底层按钮的实现
- focusable ,focusableInTouchMode,控件焦点属性;Android 如何让EditText不自动获取焦点
- android中focusable和focusableInTouchMode
- Android之focusable的使用
- android:focusable和android:focusableInTouchMode的区别
- Android的焦点(Focus)问题 focusable
- Android Focusable in Touch Mode 介绍
- Android开发,eclipse的LogCat使用技巧
- JVM GC总结
- C# 30分钟LINQ教程
- TabHost 缓存
- sort colors
- 关于android:focusable属性 - daishuguang
- 黑马程序员----多线程技术理解
- 字符串转换成int数组
- C# 关于匿名类型的特性
- Sudoku Solver
- Invocation of init method failed; nested exception is org.apache.ibatis.binding.BindingException: In
- oracle之约束
- Android小知识5
- CentOS7 - systemd服务及开启关闭服务命令