I need to update the image of each position of my listview
, the problem is that so far it updates the image, but of the wrong index, in the screenshot below there are 2 buttons, for 2 images respectively, the current problem is that the second image is updated by pressing the 2 buttons, I mean, if I press the first button, the second image is updated and if you pressed the second button, the second image is updated again, hence the first button, do not change the first image, then I leave the code you use:
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.listviewclientes, null);
holder = new CustomAdapterPublicidad.ViewHolder();
holder.publicidadboton = (Button) convertView
.findViewById(R.id.publicidadboton);
holder.publicidadimagen = (ImageView) convertView
.findViewById(R.id.publicidadimagen);
final RowItemPublicidad row_pos = rowItems.get(position);
holder.publicidadimagen.setImageResource(row_pos.getFotoPublicidad());
holder.publicidadboton.setText(row_pos.getBoton());
convertView.setTag(holder);
} else {
holder = (CustomAdapterPublicidad.ViewHolder) convertView.getTag();
}
holder.publicidadboton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(position==0){
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
Bitmap myBitmap = QRCode.from(user.getUid() + "tienda1").withHint(EncodeHintType.MARGIN, 0).bitmap();
holder.publicidadimagen.setImageBitmap(myBitmap);
notifyDataSetChanged();
}else if(position==1) {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
Bitmap myBitmap = QRCode.from(user.getUid() + "tienda2").withHint(EncodeHintType.MARGIN, 0).bitmap();
holder.publicidadimagen.setImageBitmap(myBitmap);
notifyDataSetChanged();
}
}
});
return convertView;
}
}