Esempio n. 1
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      final Holder hold;
      if (convertView == null) {
        hold = new Holder();
        convertView = View.inflate(context, R.layout.item_address, null);
        hold.name = (TextView) convertView.findViewById(R.id.address_consignee);
        hold.mobile = (TextView) convertView.findViewById(R.id.address_mobile);
        hold.detail = (TextView) convertView.findViewById(R.id.address_detail);
        hold.tag = (TextView) convertView.findViewById(R.id.address_tag);
        hold.radio = (TextView) convertView.findViewById(R.id.address_radio);
        convertView.setTag(hold);
      } else {
        hold = (Holder) convertView.getTag();
      }
      hold.name.setText(addresslist.get(position).getName());
      hold.mobile.setText(addresslist.get(position).getMobile());
      hold.detail.setText(addresslist.get(position).getDetail());
      if (addresslist.get(position).getIsUse() == 0) { // 不可用
        hold.tag.setBackgroundResource(R.drawable.unuser);
      } else {
        hold.tag.setBackgroundResource(R.drawable.address_edit);

        final String[] addressDetail = new String[4];
        addressDetail[0] = addresslist.get(position).getAdId().toString();
        addressDetail[1] = addresslist.get(position).getName();
        addressDetail[2] = addresslist.get(position).getMobile();
        addressDetail[3] = addresslist.get(position).getDetail();

        convertView.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                chose(addressDetail);
              }
            });

        hold.tag.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                editAddress(addresslist.get(position).getAdId());
              }
            });
      }
      if (addressId.equals(addresslist.get(position).getAdId())) { // 默认
        hold.radio.setBackgroundResource(R.drawable.pay_selected);
      } else {
        hold.radio.setBackgroundResource(R.drawable.pay_unselected);
      }
      return convertView;
    }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    Holder holder = null;
    if (convertView == null) {
      LayoutInflater inflater = LayoutInflater.from(mContext);
      convertView = inflater.inflate(R.layout.xianchang_add_adapter, null);
      holder = new Holder();
      holder.textView = ((TextView) convertView.findViewById(R.id.textview));
      holder.video = ((ImageButton) convertView.findViewById(R.id.video));
      holder.photo = (ImageButton) convertView.findViewById(R.id.photo);
      holder.radio = (ImageButton) convertView.findViewById(R.id.radio);
      holder.im1 = (ImageView) convertView.findViewById(R.id.imageView1);
      convertView.setTag(holder);
    } else {
      holder = (Holder) convertView.getTag();
    }

    if (contentCount != null) {
      if (contentCount[position] == 0) {
        holder.textView.setText(ss[position]);
      } else {
        holder.textView.setText(ss[position] + "    " + "( " + contentCount[position] + " )");
      }

    } else {
      holder.textView.setText(ss[position]);
    }

    if (hasContent[position] == 1) {
      holder.textView.setTextColor(Color.RED);
    } else {
      holder.textView.setTextColor(Color.BLACK);
    }

    if (isAdmin != PERSON_TYPE.XIANCHANG) {
      if (contentCount[position] == 0) {
        holder.textView.setTextColor(Color.GRAY);
        holder.im1.setVisibility(View.GONE);
      }
    }
    return convertView;
  }