The Ratingbar in the ListView contained in Android cannot respond to click events

Source: Internet
Author: User

With Ratingbar (custom icon) in the ListView, the ListView cannot respond to its own click event Onitemclicklistener. What about this?

You only need to set the android:isindicator of Ratingbar in the layout file to False, which means that the ratingbar is only as an indicator and not operable.

There are some situations where we need to customize the ListView to achieve some effect, so at this point we usually encounter a custom listview that cannot select the entire ListViewItem. That is, the Onitemclick () method in the Onitemclicklistener that cannot respond to the ListView

Usually the control that gets the focus by default has all the controls inherited by Button,checkable, which means that if your custom ListViewItem has a button or checkable child control, then the default focus is given to the child control, The ListView item can be selected based on the ability to get focus, which means that we can set the Focusable property to False for all controls contained in the ListView item. In this case, the ListView item automatically gets the focus permission, it can be selected, it will respond to the Onitemclick () method in Onitemclicklistener, however the ListView item The child control of Layout Focusable property set to False is a bit cumbersome, we can set its android:descendantfocusability= by the root control of item layout " Blocksdescendants " so that item layout shields all child controls from getting focus and does not need to reset the Focusable property for each control in item layout, In this way, the Onitenclick () method in Onitemclicklistener can be successfully responded to. For example, each item item of my LISTVIW is relativelayout, then I can set relativelayout android:descendantfocusability= "Blocksdescendants". Note: This property cannot be set to the ListView, nor does it work.

The Ratingbar in the ListView contained in Android cannot respond to click events

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.