How to use get getApplicationContext() in Adapter Class

后端 未结 3 1355
长情又很酷
长情又很酷 2020-12-07 06:16

I am using Firebase to populate my BlogRecycleadapter with blog post and get Likes from Like Buttons but when device is offline and user press Like Button , then app crashes

3条回答
  •  醉话见心
    2020-12-07 07:05

    Without sending parameter you can achecive the same thing when you are calling your network checking method use your method like below

    isNetworkStatusAvialable( holder.blogLikeBtn.getContext())
    

    Instead of passing getApplicationContext() method you can get the context from any view that you have.

    By using above approach, I am passing context of the same button that was clicked. Hope that helps you as well.

提交回复
热议问题