ExpandableListView OnChildClickListener not work

前端 未结 3 1330
既然无缘
既然无缘 2020-12-17 10:28

i have my problem with my Expandable ListView on my Android Application

this my code

package proyek.akhir;
import android.app.ListActivity;
import an         


        
相关标签:
3条回答
  • 2020-12-17 11:07

    You must activate that your children are selectable! To do that return true in your (overriden) isChildSelectable method of class ExpandableListAdapter.

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }
    
    0 讨论(0)
  • 2020-12-17 11:07

    If you are using OnChildClickListener and/or OnGroupClickListener then each child view within the group's rows and children's rows must not be focusable. For example, if you have a checkbox in the child then set the checkbox to not focusable:

    checkBox.setFocusable(false);
    

    Also, if you set the group/child convertView to clickable it will prevent the clicks from reaching the OnChildClickListener and OnGroupClickListener. If this is the case go to getGroupView, in your expListViewAdapter, and set:

    convertView.setClickable(false);
    

    Then go to getChildView, in your expListViewAdapter, and set:

    convertView.setClickable(false);
    

    After this both OnGroupClickListener and OnChildClickListener should work - granted you set the listeners in the first place (using expandableListView.setOnGroupClickListener(...) and expandableListView.setOnChildClickListener(...))

    0 讨论(0)
  • 2020-12-17 11:12

    You have to change return value is true instead of false. Make your child view selectable.

    Use this:

      @Override
            public boolean isChildSelectable(int groupPosition, int childPosition) {
                return true;
            }
    

    Instead Of:

    @Override
            public boolean isChildSelectable(int groupPosition, int childPosition) {
                return false;
            }
    
    0 讨论(0)
提交回复
热议问题