I am trying to show all data from List. Unfortunately i ve got this error " java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1".
When i try to change holder.country_timezone.setText(pozycja.getTimezones().get(0));
- it shows only first item. I would like to show all items from List.
Model
@SerializedName("timezones")
@Expose
private List<String> timezones = null;
Adapter
private Context context;
private List<JsonMain> dataList;
private List<JsonMain> filtr;
public DataAdapter(Context context, List<JsonMain> dataList) {
this.context = context;
this.dataList = dataList;
this.filtr= dataList;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_row, parent, false);
return new MyViewHolder(view);
}
@Override
public void onBindViewHolder(MyViewHolder holder, final int position) {
final JsonMain pozycja = filtr.get(position);
holder.country_flag.setImageResource(pozycja.getLogo());
holder.country_name.setText(pozycja.getName());
holder.country_subregion.setText(pozycja.getSubregion());
holder.country_nativename.setText(pozycja.getNativeName());
holder.country_capital.setText(pozycja.getCapital());
holder.country_topleveldomain.setText(pozycja.getTopLevelDomain().get(0));
holder.country_population.setText(String.valueOf(pozycja.getPopulation()));
holder.country_gini.setText(String.valueOf(pozycja.getGini()));
for(int i =0; i<filtr.size(); i++) {
holder.country_timezone.setText(pozycja.getTimezones().get(i));
}