当前位置:网站首页>RecyclerView的onBindViewHolder被同时调用两次解决方法
RecyclerView的onBindViewHolder被同时调用两次解决方法
2022-06-12 09:10:00 【谎话大方】
1、问题
我想在以下代码中mDatas.size()-1 == i 的时候修改对应组件的属性参数,但是在修改第23项的时候,第8项也被修改了
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int i)
{
if (mDatas.size()-1 != i ){
viewHolder.textView.setText(mDatas.get(i));
}else {
ivContent = viewHolder.ivContent;
viewHolder.textView.setText("");
viewHolder.editText.setVisibility(View.INVISIBLE);
viewHolder.cycleItem.setLayoutParams(new ViewGroup.LayoutParams(150, 150));
//可以在这儿设置默认图片
//viewHolder.ivContent.setBackgroundResource(R.drawable.camera);
}
}
2、解决方案
- 设置被丢弃前缓冲池中存放的最大ViewHolders数量
- 设置将视图返回到常规回收视图池之前要缓存到屏幕外的视图数
mRecyclerView.getRecycledViewPool().setMaxRecycledViews(0, 20);
mRecyclerView.setItemViewCacheSize(20);
边栏推荐
- xshell启动遇到“由于找不到mfc110.dll,无法继续执行代码的解决方法”
- day5-x
- After going to the bathroom, I figured out the ES search server
- Leetcode 336 palindrome pair (palindrome string + hash)
- Swagger documentation details
- Full alphabetic arrangement (pure alphabetic password dictionary)
- Semaphore flow control semaphore
- 2024. 考试的最大困扰度-滑动窗口
- POI library update excel picture
- Filters and listeners
猜你喜欢

Distributed transactions - Theoretical Overview

Chapter 8 - two basic problems of data processing

网页中加载二次元3D虚拟主播源码(1:项目介绍和源码)
![Offer:[day 8 dynamic planning (simple)] --- > maximum profit of stock](/img/42/000a3e601ba1771a1ee07fcd800307.jpg)
Offer:[day 8 dynamic planning (simple)] --- > maximum profit of stock

Distributed transaction solution 2: message queue to achieve final consistency

Technology cloud report: how will the industrial Internet rebuild the security boundary in 2022?

Machine learning notes - circular neural network memo list

Flink CheckPoint : Exceeded checkpoint tolerable failure threshold

node示例后台搭建

Notes on data mining in Tsinghua University (1)
随机推荐
day5-x
Minimum transfer times
Knowledge points of 2022 system integration project management engineer examination: project cost management
Node sample background setup
测试用例和bug描述规范参考
(十三)文本渲染Text
Sword finger offer:[day 9 dynamic planning (medium)] --- > maximum sum of continuous subarrays
软件测试工作经验分享,一定有你想知道的
Résoudre le problème de demander à l'élément d'être ouvert lorsque l'unit é est ouverte et que vous n'avez pas été ouvert auparavant (peut - être fermé anormalement auparavant)
Solve the problem that when unity is opened, you will be prompted that the project has been opened, but you have not opened it before (it may be closed abnormally before)
Problems that cannot be resolved by tar command
ABC253F Operations on a Matrix
Distributed task scheduling
Domain name mapping to specified IP
top命令含义
Basic SQL syntax i
(15) Tweenrunner
(JS) three digits are separated by commas, and two decimal places are reserved (or rounded)
[character set 9] will GBK be garbled when copied to unicode?
Notes on data mining in Tsinghua University (1)