Skip to content
Advertisement

Null pointer Exception on Recycler View On item click listener Activity Close when item got clicked

Hello I am new in Android development
I have tried different way to show data in RecyclerView from firebase. At first I set on click listener on item of RecyclerView and it work’s fine but After that I make some changes in code now I am trying to test it’s showing Null Exception pointer but I didn’t change anything on Adapter So why it’s showing Null pointer Exception can you please check Where I am mistaking. When I click on RecyclerView item Activity is automatically getting close.

see my Log cat

*LogCat

JavaScript

This is my View Holder/Adepter of Recycler view Check it please.

JavaScript

This is my MainActivity On start method In the this method I am showing data in Recycler View from firebase And Also set on click listener here check it please

JavaScript

And Also check Model class

JavaScript

Advertisement

Answer

Your ViewHolder is null inside the onCreateViewHolder method

Instead of using

JavaScript

Use this

JavaScript

and @Override onBindViewHolder method

JavaScript

for ref check this link

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement