Как правильно написать onBindViewHolder а то у меня он начинает ругаться на слово cardfeeds
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
CardFeed cardfeed = cardfeeds.get(position);
holder.cvUser.setText(cardfeed.getName());
holder.cvLocation.setText(cardfeed.getLocation());
holder.cvContent.setText(cardfeed.getDescription());
holder.cvPhoto.setImageResource(cardfeed.getPhoto());
}
Вот полный код адаптера
public class ContentAdapter extends
RecyclerView.Adapter<ContentAdapter.ViewHolder> {
private List<CardFeed> cardfeed;
public ContentAdapter(List<CardFeed> cardfeed) {
this.cardfeed = cardfeed;
}
private static final int LENGTH = 18;
public static class ViewHolder extends RecyclerView.ViewHolder {
CardView cv;
TextView cvUser;
TextView cvLocation;
ImageView cvPhoto;
TextView cvContent;
public ViewHolder(LayoutInflater inflater, ViewGroup parent) {
super(inflater.inflate(R.layout.card_feed, parent, false));
cvUser = (TextView) itemView.findViewById(R.id.card_user);
cvLocation = (TextView) itemView.findViewById(R.id.card_location);
cvPhoto = (ImageView) itemView.findViewById(R.id.card_image);
cvContent = (TextView) itemView.findViewById(R.id.card_text);
}
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()), parent);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
CardFeed cardfeed = cardfeeds.get(position);
holder.cvUser.setText(cardfeed.getName());
holder.cvLocation.setText(cardfeed.getLocation());
holder.cvContent.setText(cardfeed.getDescription());
holder.cvPhoto.setImageResource(cardfeed.getPhoto());
}
@Override
public int getItemCount() {
return LENGTH;
}
Вот код листа для адаптера
public class CardFeed {
private String name;
private String location;
private String description;
private int photo;
public CardFeed(){
}
public CardFeed(String name, String location, String description, int photo) {
this.name = name;
this.location = location;
this.description = description;
this.photo = photo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getPhoto() {
return photo;
}
public void setPhoto(int photo) {
this.photo = photo;
}
Обзовите ваш список cardfeeds
private List<CardFeed> cardfeeds;
public ContentAdapter(List<CardFeed> cardfeeds) {
this.cardfeeds = cardfeeds;
}
Кофе для программистов: как напиток влияет на продуктивность кодеров?
Рекламные вывески: как привлечь внимание и увеличить продажи
Стратегії та тренди в SMM - Технології, що формують майбутнє сьогодні
Выделенный сервер, что это, для чего нужен и какие характеристики важны?
Современные решения для бизнеса: как облачные и виртуальные технологии меняют рынок