setVisibility不适用于recyclerview中的所有项目

有反射

所以我有回收站视图显示4个项目,我有解锁卡并删除锁定视图的代码,所以问题是代码在前2个可见项目中起作用,但是当我滚动到项目3时,它具有相同的代码但设置了可见性即使看到呼叫记录也无法正常工作

这是代码java:

  if (datassss[position] == "Beginner") {
                holder.hpim1.setVisibility(View.VISIBLE);
                if (learnprogresdatacat1[position] == biglimits[cat]) {
                    holder.hpim1.setImageDrawable(getResources().getDrawable(R.drawable.ic_win5));
                }
            }
            if (datassss[position] == "Elementary") {
                if (learnprogresdatacat1[getexacposition] != biglimits[cat]) {
                    holder.miimlock.setVisibility(View.VISIBLE);
                }
                if (learnprogresdatacat1[getexacposition] == biglimits[cat]) {
                    holder.miimlock.setVisibility(View.GONE);
                }

                holder.hpim1.setVisibility(View.VISIBLE);
                holder.hpim2.setVisibility(View.VISIBLE);
                holder.Main_lessons_num_text.setText("4lessons");
                holder.main_big_imagex.setImageDrawable(getResources().getDrawable(R.drawable.h_sb_ele_tree));
                if (learnprogresdatacat1[position] == elelimits[cat]) {
                    holder.hpim1.setImageDrawable(getResources().getDrawable(R.drawable.ic_win5));
                    holder.hpim2.setImageDrawable(getResources().getDrawable(R.drawable.ic_win2));
                }
            }
            if (datassss[position] == "Intermediate") {
                Log.e("found limit", learnprogresdatacat1[getexacposition] + " fl");
                Log.e("limit", elelimits[cat] + " l");

                if (learnprogresdatacat1[getexacposition] != elelimits[cat]) {
                    Log.e("limit",  "unlock");
                    holder.miimlock.setVisibility(View.VISIBLE);
                } else if (learnprogresdatacat1[getexacposition] == elelimits[cat]) {
                    holder.miimlock.setVisibility(View.GONE);
                }
                holder.hpim1.setVisibility(View.VISIBLE);
                holder.hpim2.setVisibility(View.VISIBLE);
                holder.hpim3.setVisibility(View.VISIBLE);
                holder.Main_lessons_num_text.setText("5lessons");
                holder.main_big_imagex.setImageDrawable(getResources().getDrawable(R.drawable.tree2));
                if (learnprogresdatacat1[position] == interlimits[cat]) {
                    holder.hpim1.setImageDrawable(getResources().getDrawable(R.drawable.ic_win5));
                    holder.hpim2.setImageDrawable(getResources().getDrawable(R.drawable.ic_win2));
                    holder.hpim3.setImageDrawable(getResources().getDrawable(R.drawable.ic_win6));
                }
            }

这是我调试女巫显示对可见性呼叫说的日志:

2020-10-16 09:28:04.441 21853-21853 / E /限制:解锁2020-10-16 09:28:04.441 21853-21853 / E /发现限制:4 fl 2020-10-16 09:28:04.441 21853-21853 / E /极限:4升

但是您可以在模拟器视图的图像中消失在此处输入图片说明

在此处输入图片说明

都具有相同的代码,但一开始它只与可见项目一起使用,请帮助我,出什么问题了,谢谢

耶尔达

在开头和所有if语句之前添加它

holder.hpim1.setVisibility(View.GONE);
holder.hpim2.setVisibility(View.GONE);
holder.miimlock.setVisibility(View.GONE);
holder.hpim3.setVisibility(View.GONE);

更新资料

尝试在“中级” if语句中替换elelimitsbiglimits像那样:

            if (datassss[position] == "Intermediate") {
                Log.e("found limit", learnprogresdatacat1[getexacposition] + " fl");
                Log.e("limit", elelimits[cat] + " l");

                if (learnprogresdatacat1[getexacposition] != biglimits[cat]) {
                    Log.e("limit",  "unlock");
                    holder.miimlock.setVisibility(View.VISIBLE);
                } else if (learnprogresdatacat1[getexacposition] == biglimits[cat]) {
                    holder.miimlock.setVisibility(View.GONE);
                }
                holder.hpim1.setVisibility(View.VISIBLE);
                holder.hpim2.setVisibility(View.VISIBLE);
                holder.hpim3.setVisibility(View.VISIBLE);
                holder.Main_lessons_num_text.setText("5lessons");
                holder.main_big_imagex.setImageDrawable(getResources().getDrawable(R.drawable.tree2));
                if (learnprogresdatacat1[position] == interlimits[cat]) {
                    holder.hpim1.setImageDrawable(getResources().getDrawable(R.drawable.ic_win5));
                    holder.hpim2.setImageDrawable(getResources().getDrawable(R.drawable.ic_win2));
                    holder.hpim3.setImageDrawable(getResources().getDrawable(R.drawable.ic_win6));
                }
            }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章