I've try to setup a ContextMenu for my RecyclerView when i do a longClick this work perfectly but when i tried to access at getMenuInfo
his always null even in the onCreateContextMenu
i have already try this link :
For the registerForContextMenu
in the MainActivity:
@Bind(R.id.rvFeed)
RecyclerView feed;
------
feed.setAdapter(adapter);
registerForContextMenu(feed);
My onCreateContextMenu
implementation:
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
if (info == null) {
Log.d(TAG, "info == null");
}
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu_drawer, menu);
}
And the onContextItemSelected
:
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
if (info == null) {
Log.d(TAG, "info == null");
}
return super.onContextItemSelected(item);
}
main_menu_drawer
:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_drawer_delete"
android:title="@string/menufeed_menu_asread" />
</menu>