Design + Code an Android App from Scratch
This video shows how to add a menu to our Activity in Android. In the first step, create a folder called menu under res in your project directory. Right click on the folder and select new menu resource file. Call it whatever you want and after creating it, you’ll notice an XML file with a root menu tag inside it. Inside the menu tag, create as many item tags as you want and each item needs to have a title which is compulsory and an icon which is optional. The showAsAction attribute controls whether we see the menu item in the top app bar or action bar of our Activity. Override the onCreateOptionsMenu in the Activity to inflate the xml menu file using a MenuInflater object which you can retrieve by calling getMenuInflater inside our Activity. Finally override the onOptionsItemSelected method to handle menu item clicks inside our Activity.