Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Disable onClick highlight for one group in expandable list?

I have an ExpandableListView backed by an implementation of BaseExpandableListAdapter. The first group in the list functions as a header and is not expandable. I've set isChildSelectable() to return false for this group and everything's functioning normally. However, when the user clicks on this non-expandable group, the UI still highlights the row. This is a confusing and unnecessary visual cue that I'd like to eliminate.

I can't set android:listSelector="@android:color/transparent" on the ExpandableListView itself, because I do want the other list items to be highlighted upon click and expansion.

Is it possible to suppress click highlighting for that first group (only)?

like image 244
Devon Biere Avatar asked Dec 14 '25 08:12

Devon Biere


1 Answers

Try to set the individual parent view's OnClickListener to null from getGroupView().

View getGroupView(int groupPosition, boolean isExpanded, View convertView,
            ViewGroup parent) {
    ...
    convertView.setOnClickListener(null);
    ...
}
like image 126
Song Avatar answered Dec 16 '25 23:12

Song



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!