我已经看到了此链接
https://android-pratap.blogspot.com/2015/12/horizontal-recyclerview-in-vertical.html
答案 0 :(得分:0)
我尝试了太多的解决方案,但是它们都不起作用,在浪费了我两天的时间后,我终于找到了解决方案。
这是关键代码(重要),它可以滚动显示所有行中的数据
holder.recycler.setItemViewCacheSize(price.size());
这是我从第一个recyclerview bindviewholder方法添加嵌套行的方式
holder.add_item.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean addOrNot = true;
if(productSelectedBool.get(position)){
Products.get(position).setProduct_count(Products.get(position).getProduct_count()+1);
ArrayList<PriceModel> price = new ArrayList<>();
try{
if (Products.get(position).getPrice().equals(null)){
}else{
price = Products.get(position).getPrice();
}
}catch (NullPointerException e){
}
for (int i=0; i<price.size(); i++){ //check IF ALREADY ADDED
if (price.get(i).getType().equals(holder.spinner2.getSelectedItem().toString()))
addOrNot = false;
}
// if addOrNot true it should add and if addOrNot is false it means it already exist
if (addOrNot==true){
PriceModel temp = new PriceModel();
temp.setBuy("0");
temp.setMrp("0");
temp.setSell("0");
temp.setPosition(position);
temp.setType(holder.spinner2.getSelectedItem().toString());
price.add(temp);
Products.get(position).setPrice(price);
adapter = new ItemsAdapter(position, Products.get(position).getPrice());
holder.recycler.setAdapter(adapter);
holder.recycler.setItemViewCacheSize(price.size());
adapter.notifyDataSetChanged();
}else
new CustomDialogClass(CD_F_Product_Price_Update.this, "Already Added").show();
}else{
new CustomDialogClass(CD_F_Product_Price_Update.this, "Please select product first").show();
}
}
});
还有一件重要的事情,我在主recyclerview单行数据的(模型对象)中存储了嵌套的recyclerview数据