Я хочу получить данные из базы данных SQLite
и показать их в RecyclerView
, но отображается ошибка
((класс адаптера))
public class myAdapert extends RecyclerView.Adapter<myAdapert.myViewHolder> {
ArrayList<Model_class> modelClassArrayList;
public myAdapert(ArrayList<Model_class> modelClassArrayList) {
this.modelClassArrayList = modelClassArrayList;
}
@NonNull
@Override
public myViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View customView = LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.custom_row,viewGroup,false);
myViewHolder myviewHolder = new myViewHolder(customView);
return myviewHolder;
}
@Override
public void onBindViewHolder(@NonNull myViewHolder myViewHolder, int i) {
Model_class model_class = modelClassArrayList.get(i);
myViewHolder.author.setText(model_class.getAuthor());
myViewHolder.title.setText(model_class.getTitle());
myViewHolder.cost.setText(model_class.getCost());
myViewHolder.quantity.setText(model_class.getQuantity());
}
@Override
public int getItemCount() {
return modelClassArrayList.size();
}
public class myViewHolder extends RecyclerView.ViewHolder {
TextView author,title;
TextView cost,quantity;
public myViewHolder(@NonNull View itemView) {
super(itemView);
author = itemView.findViewById(R.id.authortxt);
title = itemView.findViewById(R.id.titleTxt);
cost = itemView.findViewById(R.id.costTxt);
quantity = itemView.findViewById(R.id.quantityTxt);
}
}