Ich habe den RecyclerView und seinen Adapter hinzugefügt, aber wenn ich die App erstelle, wird in der Nachrichtenansicht in Android Studio ein Erstellungsfehler angezeigt. Es zeigt auf den Fehler in RecycleAdapter, den ich erstellt habe.Fehler im RecyclerView-Adapter beim Erstellen der App
Error:(63, 12) error: cannot access ScrollingView
class file for android.support.v4.view.ScrollingView not found
Error:(20, 8) error: cannot access NestedScrollingChild
class file for android.support.v4.view.NestedScrollingChild not found
Error:(20, 88) error: type argument CategoryRecycleAdapter.ViewHolder is not within bounds of type-variable VH
where VH is a type-variable:
VH extends android.support.v7.widget.RecyclerView.ViewHolder declared in class Adapter
Error:(30, 9) error: cannot find symbol variable this
Error:(31, 9) error: cannot find symbol variable this
Error:(34, 5) error: method does not override or implement a method from a supertype
Error:(37, 16) error: an enclosing instance that contains CategoryRecycleAdapter.ViewHolder is required
Error:(40, 5) error: method does not override or implement a method from a supertype
Error:(55, 9) error: cannot find symbol method notifyDataSetChanged()
Error:(58, 5) error: method does not override or implement a method from a supertype
Hier ist der Code of Adapter:
public class CategoryRecycleAdapter extends RecyclerView.Adapter<CategoryRecycleAdapter.ViewHolder> {
Context mContext;
ArrayList<Category> alData;
public CategoryRecycleAdapter() {
}
public CategoryRecycleAdapter(Context mContext, ArrayList<Category> alData) {
this.mContext = mContext;
this.alData = alData;
}
@Override
public CategoryRecycleAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.row_category, parent, false);
return new CategoryRecycleAdapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.tvName.setText("" + alData.get(position).displayName);
Picasso.with(mContext)
.load(alData.get(position).iconUrl)
.into(holder.ivCategory);
}
public void addAll(ArrayList<Category> data) {
if (data != null) {
alData.clear();
alData.addAll(data);
}
notifyDataSetChanged();
}
@Override
public int getItemCount() {
return alData.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView tvName;
ImageView ivCategory;
public ViewHolder(View itemView) {
super(itemView);
tvName = (TextView) itemView.findViewById(R.id.tvCategory);
ivCategory = (ImageView) itemView.findViewById(R.id.ivCategory);
}
}}
Gleicher Fehler, wenn Sie Ihren Vorschlag verwenden. –