Change expandable indicator in ExpandableListView

前端 未结 7 762
野趣味
野趣味 2020-11-29 18:51

Trying to create an ExpandableListView. The initial view with the groups shows up fine. However, when I click the list item, my arrow does not change. See the images below.<

相关标签:
7条回答
  • 2020-11-29 19:53

    I had gone the way below: decide the left/right drawable for your groupView based on isExpanded flag.
    By that way, it is easier for us to customize the padding/background and other things of the indicator drawable.

    Hope it helps.

        public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
                ViewGroup parent) {
            TextView textView = (TextView) mLayoutInflater.inflate(R.layout.menu_group, null);
            textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, isExpanded ? 0 : android.R.drawable.ic_menu_more, 0);
            textView.setText(getGroup(groupPosition).toString());
            return textView;
        }
    
    0 讨论(0)
提交回复
热议问题