Considering only text colour, the following way might be applicable:
change text colour straight in getGroupView()
:
@Override
public View getGroupView(final int groupPosition, final boolean isExpanded, final View convertView, final ViewGroup parent) {
final String headerTitle = (String) getGroup(groupPosition);
View view = convertView;
if (convertView == null) {
final LayoutInflater infalInflater = (LayoutInflater) this.mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = infalInflater.inflate(R.layout.list_group, null);
}
final TextView lblListHeader = (TextView) view
.findViewById(R.id.lblListHeader);
lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle);
if (/* Check Your flag here*/ (groupPosition & 1) == 1) {
lblListHeader.setTextColor(mContext.getResources().getColor(android.R.color.holo_red_light));
} else {
lblListHeader.setTextColor(mContext.getResources().getColor(android.R.color.holo_green_light));
}
return view;
}
If You need completely different layout, then You might use getGroupTypeCount() and getGroupType() in order to define two (or more) different layout types for groups, like the following:
final static int GROUP_TYPE_COUNT = 2;
final static int GROUP_TYPE_FIRST = 0;
final static int GROUP_TYPE_SECOND = 1;
@Override
public int getGroupTypeCount() {
return GROUP_TYPE_COUNT;
}
@Override
public int getGroupType(final int groupPosition) {
return ((groupPosition & 1) == 1) ? GROUP_TYPE_FIRST : GROUP_TYPE_SECOND;
}
@Override
public View getGroupView(final int groupPosition, final boolean isExpanded, final View convertView, final ViewGroup parent) {
final String headerTitle = (String) getGroup(groupPosition);
final int type = getGroupType(groupPosition);
View view = convertView;
if (convertView == null) {
final LayoutInflater infalInflater = (LayoutInflater) this.mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
switch (type) {
case GROUP_TYPE_FIRST:
view = infalInflater.inflate(R.layout.list_group, null);
break;
case GROUP_TYPE_SECOND:
default:
view = infalInflater.inflate(R.layout.list_group_1, null);
break;
}
}
final TextView lblListHeader = (TextView) view
.findViewById(R.id.lblListHeader);
lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle);
return view;
}