I am trying to visible icons on all the items list of the recyclerview, what I want is that by pressing any on of the items, icons will be visible to all the list of the items.
help me to find out the solution.
here is my code
onBindViewholder
imageList.get(position).setDeleteImage(holder.items_image);
holder.items_image.setVisibility(View.GONE);
holder.wpImages.setOnLongClickListener(new View.OnLongClickListener() {
int i;
@Override
public boolean onLongClick(View view) {
for (i = 0; i<=imageList.size();i++){
if (imageList.get(i).getDeleteImage().getVisibility() == View.VISIBLE) {
imageList.get(i).getDeleteImage().setVisibility(View.GONE);
}else {
imageList.get(i).getDeleteImage().setVisibility(View.VISIBLE);
}
}
return false;
}
});
Could you try to add notifyDataSetChanged() after you update UI like this:
public boolean onLongClick(View view) {
for (i = 0; i<=imageList.size();i++){
if (imageList.get(i).getDeleteImage().getVisibility() == View.VISIBLE) {
imageList.get(i).getDeleteImage().setVisibility(View.GONE);
}else {
imageList.get(i).getDeleteImage().setVisibility(View.VISIBLE);
}
}
notifyDataSetChanged()
return false;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.