我有一个回收器 View ,在每一行中我有一个线性布局,我必须根据每一行的数据动态插入一些 View 。
我试过了
for(int i=0;i<4;i++){ View view = LayoutInflater.from(context).inflate(R.layout.sales_total_item_with_img,null); holder.dynamicLinearLayout.addView(view); }
the above code is written inside onBindHolder method and working but it is inflating each time I scroll and this thing is just adding more and more views
如果我做错了什么,谁能告诉我并建议我更好的方法?
最佳答案
在 for 循环之前尝试 holder.dynamic LinearLayout.removeAllViews()
关于android - 如何在回收站 View 行中添加动态 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38076869/