abu abu - 9 months ago 34
Android Question

All TextView in RecyclerView displaying same data

I have an arraylist containing 100 words. I want to assign each word to an individual textview of RecyclerView, but all the textviews of my Recyclerview show the same data, i.e the last word.

for(String s:arraylist){
viewholder.textview.setText(s);
}


Above is my Adapter Code for RecyclerView. How should I resolve this?

Answer Source

Try this:

viewholder.textview.setText(arraylist.get(position));

Instead of

for(String s:arraylist){
   viewholder.textview.setText(s);
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download