What to do if you emboss in a NullPointerException, even though everyone seems to like right?

0 like 0 dislike
Hi all!
When I go to compilenode the app,it crashes and in logcat I get the following error:
Attempt to invoke virtual method 'void android.widget.TextView.setVisibility(int)' on a null object reference

Googling, I realized that I probably just refer to the null object, but looking at the code, I realized that it is not.
Please help to correct the error.
Code MoviesAdapter.java:
public class MoviesAdapter extends RecyclerView.Adapter { private List moviesList; public class MyViewHolder extends RecyclerView.ViewHolder { public TextView title, genre, number, available; public MyViewHolder(View View) { super(view); title = (TextView) view.findViewById(R. id.title); genre = (TextView) view.findViewById(R. id.genre); number = (TextView) view.findViewById(R. id.count); available = (TextView) view.findViewById(R. id.ddd); } } public MoviesAdapter(List moviesList) { this.moviesList = moviesList; } @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(R. layout.movie_list_row, parent, false); return new MyViewHolder(itemView); } @Override public void onBindViewHolder(MyViewHolder holder, int position) { Movie movie = moviesList.get(position); holder.title.setText(movie.getTitle()); holder.genre.setText(movie.getGenre()); holder.number.setText(movie.getDocumentId() + "class"); holder.available.setVisibility(View.VISIBLE); } @Override public int getItemCount() { return moviesList.size(); } }
by | 9 views

2 Answers

0 like 0 dislike
Thank you llerik for the help.
There were two layouts: movie_list_row.xml and movie_list_row.xml(v21)
0 like 0 dislike
I think that `holder.available` all of these not-`available`, and why? Yes, to hell knows, maybe because the `onBindViewHolder ` must be inside `MyViewHolder` ? no Android developer, just guessing
110,608 questions
257,186 answers
28,644 users