Reputation: 1436
I am developing simple application similar to this one
Now, I would like to show a Context Menu (as extra options, see example below) when selecting only element One
.
The main problem I am facing right now is that I have no idea how and where to register the context menu (registerForContextMenu). What should be the view in this case?
Any help is appreciated.
Thanks in advance!
Upvotes: 0
Views: 2316
Reputation:
use this simple code in Kotlin
val wrapper: Context = ContextThemeWrapper(context, R.style.popup)
val popup = PopupMenu(wrapper, holder.binding.imgMenu)
popup.inflate(R.menu.walk_in_patient_menu)
popup.setOnMenuItemClickListener(object : PopupMenu.OnMenuItemClickListener {
override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.getItemId()) {
R.id.check_id ->
return true
else -> return false
}
}
})
popup.show()
Upvotes: 1
Reputation: 1436
I have found an alternative to Context Menus by using List Dialog. This way is much easier that the one I considered.
Upvotes: 0