Reputation: 53
I have tried other examples online and in stack overflow but cannot solve this issue I was following a tut made years ago which uses ViewHolder but it gives me error "Cannot resolve symbol 'ViewHolder'" this is for a part of my notepad tool inside of a app I'm making any help is appreciated
public class NotesAdapter extends RecyclerView.Adapter<NotesAdapter.ViewHolder> {
@NonNull
@Override
public NotesAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null;
}
public class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(@NonNull View itemView) {
super(itemView);
}
}
@Override
public void onBindViewHolder(@NonNull NotesAdapter.ViewHolder holder, int position) {
}
@Override
public int getItemCount() {
return 0;
}
}
Upvotes: 1
Views: 968
Reputation: 87
Notice the error occurs for Adapter.ViewHolder
. The program is expecting a class called Adapter
to have a nested class called ViewHolder
, which it does not.
I suspect you want to use the ViewHolder
inside your NotesAdapter
class. To use that class, all you will need to do is change Adapter.ViewHolder
to NotesAdapter.ViewHolder
.
Upvotes: 1