当我单击Button以更改ListView中的textview时,更改了最后一行或另一行textview

时间:2016-03-19 07:55:30

标签: android android-layout listview

我有这样的服装ListView:

Row1 Button1(-) TextView Button2(+)

第2行Button1(-) TextView Button2(+)

Row3 Button1(-) TextView Button2(+)

Row4 Button1(-) TextView Button2(+)

Row5 Button1(-) TextView Button2(+)

当我在任何setOnClickListener的getView中尝试Button时,更改了另一行TextView

我点击第2行/ Button2(+),因此TextView必须++(1到2)或点击第2行/ Button1(-)TextView必须{{ 1}}(2比1)但第5行中的--更改为TextView--

这是我的适配器

++

1 个答案:

答案 0 :(得分:0)

 final Holder  holder                                 = new Holder();
    if (convertView == null) {
        convertView                         = myInflater.inflate(R.layout.list_custom_froot, parent, false);

        holder.tv_lbl_name                  = (TextView)convertView.findViewById(R.id.txt_title)  ;
        holder.tv_lbl_details               = (TextView)convertView.findViewById(R.id.txt_weight  );
        holder.tv_lbl_price                 = (TextView)convertView.findViewById(R.id.txt_price)  ;
        holder.txt                          = (TextView)convertView.findViewById(R.id.txt_meghda  r);
        holder.tv_img_pic                   = (ImageView)convertView.findViewById(R.id.img);
        holder.btn2                          = (ImageButton)convertView.findViewById(R.id.btn_kam  );
        holder.btn1                            = (ImageButton)convertView.findViewById(R.id.btn_zia  d);
        holder.btn_more                     = (ImageButton)convertView.findViewById(R.id.btn_mor  e);

        convertView.setTag(holder);
    } else {
        holder = (Holder) convertView.getTag();
    }

    holder.tv_lbl_name.setText                  ((list.get(position).getname()));
    holder.tv_lbl_details.setText               ((list.get(position).getdetails()));
    holder.tv_lbl_price.setText                 ((list.get(position).getprice()));
    holder.txt  ((list.get(position).gettextvalue)); //create the textvalue string in dm_Mive class nd set value empty

    holder.btn1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
          int butttonpostion = (Integer) buttonView.getTag();
       //  String v1=   holder.txt  .gettext();
        String v1=list.get(butttonpostion).gettextvalue);// direct get value to list

        dm_Mive dm= new dm_Mive()
        dm_Mive.settextvalue(v1);
       dm_Mive.setname(list.get(buttonpostion).getname())
        ..
        ....
      friendlist.set(butttonpostion, dm);

        }
    });