RecyclerView.Adapter draws only one record, although there are more of them in the list, it draws only the first one, under the debug it looked - it comes out after the first record is drawn. Tell me what could be the problem

 public class TripAdapter extends RecyclerView.Adapter<TripAdapter.TripViewHolder> { public List<Refueling> refueling; public TripAdapter(List<Refueling> refueling) { this.refueling = refueling; } @Override public TripViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new TripViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.page_refueling, parent, false)); } @Override public void onBindViewHolder(TripViewHolder holder, int position) { holder.price.setText("Заправил на:" + refueling.get(position).price.toString()); holder.priceFuel.setText("Цена : " + refueling.get(position).price_fuel.toString()); holder.fuel.setText("Заправил (л): " + String.format("%.2f",Double.parseDouble(refueling.get(position).fuel_l))); holder.distance.setText("Проехал (км): " + refueling.get(position).distance.toString()); } @Override public int getItemCount() { return refueling.size(); } public class TripViewHolder extends RecyclerView.ViewHolder { private TextView priceFuel; private TextView fuel; private TextView price; private TextView distance; public TripViewHolder(View itemView) { super(itemView); priceFuel = (TextView) itemView.findViewById(R.id.price_fuel_rv); fuel = (TextView) itemView.findViewById(R.id.fuel_rv); price = (TextView) itemView.findViewById(R.id.price_rv); distance = (TextView) itemView.findViewById(R.id.distance_rv); } } 

}

  rv.setLayoutManager(new LinearLayoutManager(this)); rv.setAdapter(new TripAdapter(Refueling.refuelings)); 

enter image description here

  • Where is the constructor and how do the data get into the adapter? - pavlofff
  • The adapter has no constructor and a data set passed through this constructor that can be iterated. The fact that you have there some kind of external class with the data adapter is not at all interesting. - pavlofff
  • Added constructor, adapter sees data, but draws only the first record - user208914
  • one
    I would venture to assume (I had such a rake) that you have your item height has a match_parent. Try scrolling through your list. See if I'm right or not - plesser
  • Yes ... you are right ... it's sad)) Thank you - user208914

0