简体   繁体   中英

Cannot resolve symbol 'ViewHolder' Java Android studio

无法解析符号“ViewHolder”的错误

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;
    }
}

Adapter.ViewHolder更改为RecyclerView.ViewHolder

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM