The listview item is clicked and the button in it is clicked to take effect

Source: Internet
Author: User

Android development in the ListView often has a button or imagebutton such as need to be clicked on the control, if not add some special restrictions, it is possible to the ListView item Click event or button click event, one of which cannot respond. The situation I encountered was that the ListView item could not respond to the Click event.

Workaround, add the following attribute to the XML file of the ListView item:

1) Add attribute android:descendantfocusability= "Blocksdescendants" to the root element of the entire XML file, such as LinearLayout

2) The controls that are clicked, such as ImageButton, add properties Android:focusable= "false" and android:clickable= "true"

Perfect solution!

This article was reproduced from: http://blog.csdn.net/dinglin_87/article/details/7878686#comments

The listview item is clicked and the button in it is clicked to take effect

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.