android:descendantFocusability用法

在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会覆盖子类控件而直接获得焦点

常用的是第三个。

posted @ 2016-09-05 22:38  快乐的小狼  阅读(247)  评论(0编辑  收藏  举报