ExpandableListView OnChildClickListener not work

前端 未结 3 1343
既然无缘
既然无缘 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

    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(...))

提交回复
热议问题