本文介绍了将多个ArrayList添加到RecyclerView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在recyclerview中以列表格式列出文本和图像,并在每一行中显示此代码,但我知道它的错误原因仅显示了一行,我该如何编辑代码.还在学习Java
I am trying to list text and images in a list format in the recyclerview and display in each row this my code and I know its wrong cause its only showing one row how must I edit the code. Still learning java
ArrayList<DataList> dataList = new ArrayList<DataList>();
for (int i = 0; i < 1; i ++ ) {
dataList.add(new DataList(
"France",
"Russia",
R.drawable.lt1,
"America",
"Europe",
R.drawable.lt2
));
}
ArrayList<DataList2> dataList2 = new ArrayList<DataList2>();
for (int i = 0; i < 1; i ++ ) {
dataList2.add(new DataList2(
"South Africa",
"Brazil",
R.drawable.lt1,
"New Zeland",
"Pakistan",
R.drawable.lt2
));
}
推荐答案
您应该将它们添加到RecyclerView随后将显示的项目的一个主ArrayList中.
You should be adding them to one main ArrayList of items which the RecyclerView will then show.
这篇关于将多个ArrayList添加到RecyclerView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!