Description for context menu:

These are floating menus that are displayed when a user long clicks on the widget that’s ought to show the Menu.
Steps to show context menu are given below.
In strings.xml write code given below
<string name =”delete”>delete</string>
<string name=”add”>add</string>
<string name=”update”>update</string>
<string name=”settings”>settings</string>
Add menu 
Res->new->Android res file-> menu
Add menu items to drawable
Drawable-> new-> vector asset-> settings
And add, update same as in above step
Set I’d and title for all In activity main xml- 
Show action always 
Write a code in main activity
Override fun on context item selected(item.menuitem):boolean{
Val msg=when(item.itemid)
R.menu(item_add->”add is clicked”
R.menu(item_delete->”delete is clicked”
R.menu(item_update->”update is clicked”
else->”settings is clicked”
}
Toast.make toasttext(context this,msg,toast
.LENGTH_LONG).show()
return true

Youtube video link:

https://youtu.be/tdq_olG1e3g

Leave a Reply

Your email address will not be published. Required fields are marked *