我正在尝试实现一个RecyclerView,当单击每个项目时,将弹出一个上下文菜单。
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.
我的问题是,通过使用getMenuInfo()检索信息,我一直变得空。即,当我从上下文菜单中选择一项时,这就是我得到的内容
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:尝试从字段读取空对象引用上的'long com.x.lib.RVCoursesContextMenu $ RecyclerContextMenuInfo.id'
java.lang.NullPointerException: Attempt to read from field 'long com.x.lib.RVCoursesContextMenu$RecyclerContextMenuInfo.id' on a null object reference
我的代码与此 answer 非常相似。
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.
推荐答案public static class ViewHolder extends RecyclerView.ViewHolder { Context cxt; public ViewHolder(View itemView, int ViewType, Context cnxt) { this.cxt = cnxt; } }
更多推荐
Android:RecyclerView项目Contextmenu问题
发布评论