示例#1
0
  @Override
  public View bindView(int arg0, View convertView, ViewGroup arg2) {
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.item_add_friend, null);
    }
    final BmobChatUser contract = getList().get(arg0);
    TextView name = ViewHolder.get(convertView, R.id.name);
    ImageView iv_avatar = ViewHolder.get(convertView, R.id.avatar);
    Button btn_add = ViewHolder.get(convertView, R.id.btn_add);
    String avatar = contract.getAvatar();

    if (avatar != null && !avatar.equals("")) {
      ImageLoader.getInstance().displayImage(avatar, iv_avatar, ImageLoadOptions.getOptions());
    } else {
      iv_avatar.setImageResource(R.drawable.default_head);
    }

    name.setText(contract.getUsername());
    btn_add.setText("添加");
    btn_add.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            // 生成进度条
            final ProgressDialog progress = new ProgressDialog(mContext);
            progress.setMessage("正在添加...");
            progress.setCanceledOnTouchOutside(false);
            progress.show();
            // 向陌生人发送添加好友请求
            BmobChatManager.getInstance(mContext)
                .sendTagMessage(
                    BmobConfig.TAG_ADD_CONTACT,
                    contract.getObjectId(),
                    new PushListener() {

                      @Override
                      public void onSuccess() {
                        progress.dismiss();
                        ShowToast("发送请求成功,等待对方验证!");
                      }

                      @Override
                      public void onFailure(int arg0, final String arg1) {
                        progress.dismiss();
                        ShowToast("发送请求失败,请重新添加!");
                        ShowLog("发送请求失败:" + arg1);
                      }
                    });
          }
        });
    return convertView;
  }
 @Override
 public View bindView(int arg0, View convertView, ViewGroup arg2) {
   // TODO Auto-generated method stub
   if (convertView == null) {
     convertView = mInflater.inflate(R.layout.item_blacklist, null);
   }
   final BmobChatUser contract = getList().get(arg0);
   TextView tv_friend_name = ViewHolder.get(convertView, R.id.tv_friend_name);
   ImageView iv_avatar = ViewHolder.get(convertView, R.id.img_friend_avatar);
   String avatar = contract.getAvatar();
   if (avatar != null && !avatar.equals("")) {
     ImageLoader.getInstance().displayImage(avatar, iv_avatar, ImageLoadOptions.getOptions());
   } else {
     iv_avatar.setImageResource(R.drawable.default_head);
   }
   tv_friend_name.setText(contract.getUsername());
   return convertView;
 }