3

I am trying to implement a RecyclerView, that each item when clicked, a context menu will pop up.

I have referred the answers/comments from this question on how to to do what I wanted.

My problem is, I keep getting null by using getMenuInfo() to retrieve info. Ie, When I select an item from the context menu, this is what I get

java.lang.NullPointerException: Attempt to read from field 'long com.x.lib.RVCoursesContextMenu$RecyclerContextMenuInfo.id' on a null object reference

My code for this is very similar to this answer .

I have been looking for a solution for this for a very long time, would really appreciate if someone could help me on this.

Community
  • 1
  • 1
Tim
  • 63
  • 1
  • 6

1 Answers1

0
public static class ViewHolder extends RecyclerView.ViewHolder {
    Context cxt;

    public ViewHolder(View itemView, int ViewType, Context cnxt) {
        this.cxt = cnxt;
    }
}
sschrass
  • 7,014
  • 6
  • 43
  • 62
Yogesh Rathi
  • 6,331
  • 4
  • 51
  • 81