-1

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
        ));
    }
Jacques Krause
  • 5,523
  • 9
  • 27
  • 43

2 Answers2

0

You are iterating the loop only 1 time .

for (int i = 0; i < 1; i ++ ) {
                    /\
                    ||
                 Iterate it more times
}

Like

for (int i = 0; i < n; i ++ ) {// n times or as much as you want 

}
Neeraj Jain
  • 7,643
  • 6
  • 34
  • 62
  • thats not the problem it must only show DataList one time then DataList2 in the second row under it but its only showing DataList – Jacques Krause Mar 23 '15 at 08:42
0

You should be adding them to one main ArrayList of items which the RecyclerView will then show.

Phillip Godzin
  • 660
  • 1
  • 9
  • 21