ListFragment OnListItemClick not being called

后端 未结 11 1457
盖世英雄少女心
盖世英雄少女心 2020-11-27 05:53

I have a class that extends ListFragment, and it overrides the OnListItemClick method. I am also doing this in another ListFragment the same way (and the method gets called)

11条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 06:38

    A CheckBox is focusable by default. This means that a click on a list item will be interpreted as toggling the CheckBox and will not reach your onListItemClick(…) method. This internal quirk of ListView means that any focusable widget that appears in a list item layout (like a CheckBox or a Button) should be made non-focusable to ensure that a click on a list item will work as you expect. Because your CheckBox only reports information and is not tied to any application logic, there is a simple solution. You can define the CheckBox as not focusable.

    from The Big Nerd Ranch Guide book

提交回复
热议问题