0

firstly, I have reviewed all the answers, below. But my problem still continues.

How to sort 2 dependent ArrayLists?

Add Multiple ArrayLists to RecyclerView

arraylist add to new recyclerview

how to work with Multidimensional arraylist?

How to work with Java ArrayList?

how to search arraylist data in recyclerview in fragment

How putExtra in RecyclerView with arraylist from JSON

Print 2 ArrayLists with specific format

I did the following, the way. But my application opens, and it closes immediately.

MainActivity.java

ArrayList<String> ulkeler = new ArrayList<>();
ulkeler.add("TÜRKİYE");
ulkeler.add("RUSYA");
ulkeler.add("FRANSA");
ulkeler.add("İNGİLTERE");
ulkeler.add("JAPONYA");
ulkeler.add("ALMANYA");


ArrayList<String> ulkelertwo = new ArrayList<>();
ulkeler.add("TÜRKİYEw");
ulkeler.add("RUSYAw");
ulkeler.add("FRANSAw");
ulkeler.add("İNGİLTEREw");
ulkeler.add("JAPONYAw");
ulkeler.add("ALMANYAw");

adapter = new MyAdapter(this,ulkeler,ulkelertwo);
rv.setAdapter(adapter);

onBindViewHolder

public void onBindViewHolder(@NonNull one holder, int position) {
    String ulke = ulkelerListe.get(position);
    String ulketwo = ulkelerListetwo.get(position);

    holder.textView.setText(ulke);
    holder.textViewtwo.setText(ulketwo);



}

getItemCount public int getItemCount() {

    return ulkelerListe.size()+ulkelerListetwo.size();
}

Logcat

https://github.com/prensmiskin/vollley-one/issues/2#issue-507813748

I did the following, taking advantage of the answer, but it didn't work. Two ArrayList one RecyclerView Adapter

2 Answers2

0

Size of GetItemCount() is more than the list itemspassed for binding to recycler view. During getting the data at index which is not in the list causes exception.

Ashok Kumar
  • 1,226
  • 1
  • 10
  • 14
0

To make this working in your approach, you have to ensure two things:

  1. ulkeler and ulkelertwo must have same size.
  2. Return ulkelerListe.size only from getItemCount()
Md. Asaduzzaman
  • 14,963
  • 2
  • 34
  • 46