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)>”add is clicked”>”delete is clicked”>”update is clicked”
else->”settings is clicked”
Toast.make toasttext(context this,msg,toast
return true

Youtube video link:

Leave a Reply

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