码迷,mamicode.com
首页 > 移动开发 > 详细

android:descendantFocusability用法

时间:2016-09-05 23:38:50      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

在ListView的item布局中可能存在CheckBox、Button、ImageButton等类似的课点击控件。这时就会发生抢焦点问题。也就是item的焦点被子控件抢走。

API描述如下:

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.

 

技术分享

 

有三个属性值:

beforeDescendantsviewgroup会优先其子类控件而获取到焦点

afterDescendants:viewgroup只有当其子类控件不需要获取焦点时才获取焦点

blocksDescendants:viewgroup会覆盖子类控件而直接获得焦点

常用的是第三个。

android:descendantFocusability用法

标签:

原文地址:http://www.cnblogs.com/freedomwolf/p/5843939.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!