android ListItem 焦点获取问题
?
通常Android提供给我们的ListItem布局不是我们需要,可能我们想在里面添加一些图片,按钮等等,但是这时候这些可以获得焦点的子控件将会提前获取焦点,从而Item没有了获取焦点的能力了,这时候我们需要设置子控件获取焦点的能力为false,但是如果子控件较多时,这样设置比较麻烦,我们可以在我们自定义的item的根属性下添加:android:descendantFocusability="blocksDescendants"这样item将会阻止子控件获取焦点。该属性还有其他两种可能:"beforeDescendants"和"afterDescendants"。分别为在子控件之前和之后。/**?? ? * This view will get focus before any of its descendants.?? ? */
public static final int FOCUS_BEFORE_DESCENDANTS = 0×20000;
/**?? ? * This view will get focus only if none of its descendants want it.?? ? */
public static final int FOCUS_AFTER_DESCENDANTS = 0×40000;
/**?? ? * This view will block any of its descendants from getting focus, even?? ? * if they are focusable.?? ? */
public static final int FOCUS_BLOCK_DESCENDANTS = 0×60000;
?