@Override
  public View getChildView(
      int groupPosition,
      int childPosition,
      boolean isLastChild,
      View convertView,
      ViewGroup parent) {
    ViewHolderChild holder;
    if (convertView == null) {
      LayoutInflater inflater =
          (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = inflater.inflate(mLayout, null);

      holder = new ViewHolderChild();
      holder.text1 = (TextView) convertView.findViewById(android.R.id.text1);
      holder.text2 = (TextView) convertView.findViewById(android.R.id.text2);

      convertView.setTag(holder);
    }
    holder = (ViewHolderChild) convertView.getTag();

    QueryCategorySubCategory categorySubCategory =
        (QueryCategorySubCategory) getChild(groupPosition, childPosition);

    if (categorySubCategory != null) {
      holder.text1.setText(categorySubCategory.getSubCategName());
      holder.text2.setText(categorySubCategory.getCategName());

      holder.text2.setTextColor(mContext.getResources().getColor(android.R.color.darker_gray));

      boolean isChildSelected =
          mIdChildChecked
              == ((QueryCategorySubCategory) getChild(groupPosition, childPosition))
                  .getSubCategId();
      if (holder.text1 instanceof CheckedTextView) {
        ((CheckedTextView) holder.text1).setChecked(isChildSelected);
      } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        convertView.setBackgroundColor(
            mContext
                .getResources()
                .getColor(isChildSelected ? R.color.holo_blue_light : android.R.color.transparent));
      }
    }

    return convertView;
  }
Exemplo n.º 2
0
    @Override
    public View getRealChildView(
        int groupPosition,
        int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {
      ViewHolderChild holder = null;

      if (convertView == null) {
        convertView = inflater.inflate(R.layout.widget_nick_single, null);
        holder = new ViewHolderChild();
        holder.nickView = (TextView) convertView.findViewById(R.id.nicklist_nick_view);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolderChild) convertView.getTag();
      }
      final IrcUser entry = getChild(groupPosition, childPosition);
      final IrcMode mode = getGroup(groupPosition).first;
      convertView.setBackgroundColor(ThemeUtil.getNickBg(mode));

      holder.nickView.setText(entry.nick);
      if (entry.away) {
        holder.nickView.setTextColor(ThemeUtil.Color.bufferParted);
      } else {
        holder.nickView.setTextColor(ThemeUtil.Color.bufferRead);
      }

      holder.nickView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              queryUser(entry.nick);
            }
          });

      return convertView;
    }