I have the context menu layout:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/share_btn"
android:icon="@drawable/ic_delete_black_24dp"
android:title=""
app:showAsAction="always"/>
<item
android:id="@+id/edit_btn"
android:icon="@drawable/ic_edit_black_24dp"
android:title=""
app:showAsAction="always"/>
<item
android:id="@+id/remove_btn"
android:icon="@drawable/ic_delete_black_24dp"
android:title=""
app:showAsAction="always"/>
</menu>
And Fragment, where I am trying to to show the menu:
class OverviewFragment: Fragment() {
/* some code */
override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenu.ContextMenuInfo?) {
super.onCreateContextMenu(menu, v, menuInfo)
this.activity!!.menuInflater.inflate(R.menu.binge_card_menu, menu)
}
/*some code */ }
But the layout didn't show:
But listeners worked, and if I make the menu programmatically everything shows correctly, so I don't know why.
