Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting different indicators for different groups in android

I would like to know how to set different indicators for different groups in ExpandableListView.

I tried :

if(true condition for a group say groupA)
{
    getExpandableListView().setGroupIndicator(getResources().getDrawable(R.drawable.image));
}

but the above code sets the indicator for all the groups in the view ! I want different indicators for all the groups like :

groupA having a different indicator;groupB having a different indicator;groupC having a different indicator

where groupA,groupB and groupC have certain number of children.

Can anyone suggest something ?

-Adithya.

like image 391
Adithya Avatar asked Nov 14 '22 17:11

Adithya


1 Answers

To create different indicator in expandable listview. First of all create Adapter for expandable listView. Create custom layout for all different indicator.

Now in your getGroupView method

@Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {  
LayoutInflater infalInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);


            if (groupPosition == 0) {
                convertView = infalInflater.inflate(INFLATE YOUT LAYOUT HERE, null);
            } else if (groupPosition == 1) {
                convertView = infalInflater.inflate(INFLATE YOUT LAYOUT HERE, null);
            }else if (groupPosition == 2) {
                convertView = infalInflater.inflate(INFLATE YOUT LAYOUT HERE, null);
            }
}

Try this this is work for me... Hope this is helpful for you..

like image 112
Arvind Kanjariya Avatar answered Dec 29 '22 22:12

Arvind Kanjariya