The Onitemclicklistener of the ListView is not responding to the workaround

Source: Internet
Author: User

Sometimes you encounter a Onitemclicklistener event in the ListView that is not responding,main reason: The child element of the ListView contains elements such as button or ImageButton, and the button has a priority higher than the ListView so it cannot listen on the item's click event. Workaround: Add "android:descendantfocusability=" Blocksdescendants "to the root node of item. Add: This property of android:descendantfocusability is defined as the relationship between the ViewGroup and its child controls when one gets the focus for the view. There are three property values for android:descendantfocusability:  Beforedescendants:viewgroup takes precedence over its subclass control and gets to focusAfterdescendants:viewgroup gets focus only if its subclass control does not need to get focusBlocksdescendants:viewgroup overrides the subclass control and gets the focus directly usually we use the third type, that is, the root layout of the item layout plus the android:descendantfocusability= "blocksdescendants" property is good.

The Onitemclicklistener of the ListView is not responding to the workaround

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.