Context menu in android is used to open a menu when a Long Click is made on list-view. A menu pop’s up giving options like share, delete, edit,etc,.

In this tutorial i will be showing you the context menu with five different options.

Inserting values into String [ ] and showing these values in list-view, and by long click on thisĀ  values you can get a options menu.

 

MainActivity.java

 

 

Adding Listview and text view to the xml file.

 

activity_main.xml

 

AndroidManifest.xml

Output:

 

contextmenu2

If you have any query’s in this tutorial let me know through comments below.

Show Buttons
Hide Buttons
Read previous post:
Android Tutorial on SplashScreen

Close