How can I save the default behavior of the list item ExpandableListView when delivering a group view that contains more than just a TextView?

Is it possible to save the behavior of the default list item list parameter ExpandableListView when presenting a group view that contains more than just a TextView. The behavior I'm talking about is where clicking on an element changes the background color to yellow.

Every time I provide a group view that contains, for example, TextView and Button, I lose the behavior.

+4
source share
2 answers

Another option is to set the root ViewGroup to lock focus for child views.

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

+2
source

The inclusion of any kind that can be focused in the layout of the user list will cause the list item to stop responding. When implementing this type of custom view, the focusable property of each view in the list item view must be set to false. This can be done either in xml or in code. With one exception, ImageButton will not respond to customizing its custom 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); 
+1
source

Source: https://habr.com/ru/post/1338690/


All Articles