Android uses ListView to set the "android:clickable="false" attribute to the control, and there is still no callback when the Item is clicked

        When using ListView to develop a list, use

mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
}

After the method is clicked, there is no callback click event;

the reason:

A clickable control in the Item list item gets the focus, and first gets the click processing right;

Solution:

1. Add the following properties to the controls in the list item

android:focusableInTouchMode="false"

android:clickable="false"

android:focusable="false"

 2. Add the following properties under the root control in the ListItem layout file to make the child controls not focus:

descendantFocusability attribute

3. When there is a custom control in the ListItem, usually the custom is a combined control. When the custom control is set to be unfocused, the internal controls that make up the custom control, such as Button, may still be able to To get the focus, you need to set the non-clickable attribute in the code

myButton.setClickable(false);

Guess you like

Origin blog.csdn.net/weixin_42433094/article/details/110771687