Summary of controls with events such as Android ListView and Button,imagebutton

Source: Internet
Author: User

?
1 2 3 4 public ImageButton(Context context, AttributeSet attrs, int defStyle) {     super(context, attrs, defStyle);     setFocusable(true);}

In the ListView (or Expandablelistview), the item's view is handled in a special process, and the Convertview can be used to reduce parsing of XML files and improve efficiency. But if you parse it yourself once and then save it with a variable, then only the last view can be displayed correctly, stating that each item's view is a different instance, so that each view is in fact a separate response event that can be added like a button.

There are several ways to avoid buttons or ImageButton to rob the whole item of focus

  

    1. The button setting Focusable=false,imagebutton to be set Ib.setfocusable (false) by code, because the source bug
?
1 2 3 4 public ImageButton(Context context, AttributeSet attrs, int defStyle) {     super(context, attrs, defStyle);     setFocusable(true);}

2. Set android:descendantfocusability= "Blocksdescendants" in the root viewgroup of the layout of item, which will also enable other view to respond to the focus

But in the actual development process, I found that if the Ischildselectable method in the Baseexpandablelistadapter of Expandablelisview returns True after the overwrite, otherwise it will not respond ItemClick

?
1 2 3 4 @Override public boolean isChildSelectable(int groupPosition, int childPosition) {     return true;}

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.