@Override public View getGroupView( int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { ViewHolderGroup holder = null; if (convertView == null) { convertView = inflater.inflate(R.layout.widget_nick_group, null); holder = new ViewHolderGroup(); holder.nameView = (TextView) convertView.findViewById(R.id.nicklist_group_name_view); holder.countView = (TextView) convertView.findViewById(R.id.nicklist_group_count_view); convertView.setTag(holder); } else { holder = (ViewHolderGroup) convertView.getTag(); } Pair<IrcMode, List<IrcUser>> group = getGroup(groupPosition); convertView.setBackgroundColor(ThemeUtil.getNickBg(group.first)); holder.nameView.setTextColor(ThemeUtil.getModeColor(group.first)); holder.countView.setTextColor(ThemeUtil.getModeColor(group.first)); if (group.second.size() < 1) { convertView.setVisibility(View.GONE); holder.nameView.setVisibility(View.GONE); holder.countView.setVisibility(View.GONE); } else { convertView.setVisibility(View.VISIBLE); holder.nameView.setVisibility(View.VISIBLE); holder.countView.setVisibility(View.VISIBLE); holder.nameView.setText( getResources().getQuantityString(group.first.modeName, group.second.size())); holder.countView.setText(group.first.icon + " " + group.second.size()); } return convertView; }
@Override public View getGroupView( int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { ViewHolderGroup holder; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(mLayout, null); holder = new ViewHolderGroup(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); convertView.setTag(holder); } else { holder = (ViewHolderGroup) convertView.getTag(); } // check position and size of ArrayList if (groupPosition < mCategories.size()) { holder.text1.setText(((TableCategory) mCategories.get(groupPosition)).getCategName()); boolean isGroupChecked = mIdGroupChecked == ((TableCategory) mCategories.get(groupPosition)).getCategId(); if (holder.text1 instanceof CheckedTextView) { ((CheckedTextView) holder.text1) .setChecked(isGroupChecked && mIdChildChecked == ListView.INVALID_POSITION); if (isGroupChecked) { ((ExpandableListView) parent).expandGroup(groupPosition, true); } } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { convertView.setBackgroundColor( mContext .getResources() .getColor( isGroupChecked && mIdChildChecked == ExpandableListView.INVALID_POSITION ? R.color.holo_blue_light : android.R.color.transparent)); } } return convertView; }