How can ExpandableListView's default list item press behavior be preserved when supplying a group view that contains more than just a TextView?

£可爱£侵袭症+ 提交于 2019-12-05 18:44:08

Another option is setting your root ViewGroup to block focus for child views.

Example: <LinearLayout ... android:descendantFocusability="blocksDescendants" />

Including any view that is focusable within a custom list item layout will cause the list item to stop responding to presses. When implementing this sort of custom view, the focusable property of each view within the list item view must be set to false. This can be done either in xml or code. With one exception - ImageButton will not respond to setting its focusable field via xml. It only works in code with ImageButton.

<TextView
    android:id="@+id/text1"
    android:focusable="false"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

Or

imageButtonInstance.setFocusable(false);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!