简体   繁体   English

如何在recyclerview的所有项目中显示图标?

[英]how to visible icon in all the items of recyclerview?

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.我试图在recyclerview的所有项目列表上显示图标,我想要的是通过按任何项目,所有项目列表都可以看到图标。

help me to find out the solution.帮我找出解决方案。

here is my code这是我的代码

onBindViewholder 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:您可以在更新 UI 后尝试添加notifyDataSetChanged() ,如下所示:

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM