Intent fails because of Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()

后端 未结 2 529
轻奢々
轻奢々 2021-01-28 02:30

What I have: I have a RecyclerView with images of bars, coffee shops. etc

What I want: That when you click on one of these images I show you the info of the selected pla

2条回答
  •  深忆病人
    2021-01-28 03:11

    You need to fetch the context in adapter. I've another solution for. You can get context using the code below

    context = holder.foto.getContext();
    

    So, we will get context from foto component in adapter. Lets try!

    UPDATE

    You need to put that code in onBindViewHolder and above

    if (position == 0){
    

提交回复
热议问题