我试图在recyclerview中以列表格式列出文本和图像,并在每行中显示我的代码,我知道它的错误因为它只显示一行我必须如何编辑代码。还在学习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
));
}
答案 0 :(得分:0)
您只在1
时间迭代循环。
for (int i = 0; i < 1; i ++ ) {
/\
||
Iterate it more times
}
像
for (int i = 0; i < n; i ++ ) {// n times or as much as you want
}
答案 1 :(得分:0)
您应该将它们添加到RecyclerView随后将显示的项目的一个主ArrayList中。