Android ListView 中子控件无法获取焦点的解决方法(主要针对键盘操作)
2012-10-13 16:41
886 查看
1。android:descendantFocusability
一般情况下为了使用ListView的onItemClick,onItemLongClick方法,屏蔽子控件对焦点的获取,所以应将该值由
blocksDescendants 改为 afterDescendants
ps:
android:descendantFocusability
Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.
Must be one of the following constant values.
Constant Value Description
beforeDescendants 0 The ViewGroup will get focus before any of its descendants.
afterDescendants 1 The ViewGroup will get focus only if none of its descendants want it.
blocksDescendants 2 The ViewGroup will block its descendants from receiving focus
2.在×××Adapter类的getView中调用子控件的setFocusable属性,及实现相应的Click函数(由于子控件获取焦点后,listview的onItemClick,onItemLongClick不再会被调用,
所以也一并实现,对于onItemLongClick函数,注意要返回TRUE,否则会发现该函数相应的代码会走两遍,估计是ListView的onItemLongClick被触发,有待深究)。
3.调用ListView的setItemsCanFocus(TRUE)函数
一般情况下为了使用ListView的onItemClick,onItemLongClick方法,屏蔽子控件对焦点的获取,所以应将该值由
blocksDescendants 改为 afterDescendants
ps:
android:descendantFocusability
Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.
Must be one of the following constant values.
Constant Value Description
beforeDescendants 0 The ViewGroup will get focus before any of its descendants.
afterDescendants 1 The ViewGroup will get focus only if none of its descendants want it.
blocksDescendants 2 The ViewGroup will block its descendants from receiving focus
2.在×××Adapter类的getView中调用子控件的setFocusable属性,及实现相应的Click函数(由于子控件获取焦点后,listview的onItemClick,onItemLongClick不再会被调用,
所以也一并实现,对于onItemLongClick函数,注意要返回TRUE,否则会发现该函数相应的代码会走两遍,估计是ListView的onItemLongClick被触发,有待深究)。
3.调用ListView的setItemsCanFocus(TRUE)函数
相关文章推荐
- android:descendantFocusability用法简析 解决listview中子控件导致item不能获取焦点
- Android listview 的 item 点击无效(无法获取焦点)的解决方法
- 通过android:descendantFocusability解决listview每一项或项中view无法获取焦点的问题
- [Android开发] 解决listview 的item无法获得焦点
- ListView更新后无法响应点击事件解决方法(失去焦点)
- ListView里面有EditTextView,解决弹出键盘后EditView不能获取焦点的问题
- Quill编辑器IOS下无法获取焦点的解决方法
- Android基础控件ListView的使用与焦点冲突解决
- Android开发中listView的item无法获取焦点
- android ListView显示多个类型item 和 item中控件抢夺焦点解决办法
- android 文字太长跑马灯获不到焦点无法显示效果的一种解决方法
- Android开发之ListView+EditText-要命的焦点和软键盘问题解决办法
- android notifydatasetchanged() 无法实时更新listview内容的解决方法
- Gridview Row事件响应方法无法获取其它UpdatePanel中控件数据的解决办法
- Android软键盘弹出时把布局顶上去,控件乱套解决方法
- Android 软键盘弹出时把布局顶上去,控件乱套解决方法
- ListView里面有EditTextView,解决弹出键盘后EditView不能获取焦点的问题
- 遇到的selenium下拉框无法操作解决方法-键盘操作事件
- CodedUI Test 测试WPF程序,无法获取控件属性值的解决方法
- Android软键盘弹出时把布局控件顶上去的解决方法