?
| 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
- 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;} |