Create menu resource directory (res/menu) in Android Studio

Whenever you create a Blank Activity in Android Studio, a menu resource directory (i.e. menu resource file i.e. res/menu) and file gets automatically created, with auto-generated code in java class file. But what if you want to add an Empty Activity, can you create a menu resource directory and file manually? The answer is yes, this is what we will cover in this post.

What we will learn?

  • The difference between Blank Activity and Empty Activity?
  • How to add an Empty Activity in Android Studio?
  • How to create a menu resource directory (res/menu)?
  • How to create a menu resource file in menu resource directory (res/menu/menu_main.xml).

Before moving further, since we will be discussing  Blank Activity and Empty Activity, here are the differences
between both the activities,

Here are the steps with which you can easily add a menu resource directory and file in Empty Activity in Android Studio,

Adding Menu Resource Directory (res/menu)

Step 1: Open your project and right click on res, then click “New”, then “Android resource directory”,

Figure 1- Add Android resource directoryFigure 1: Add Android resource directory

Step 2:

After that change the resource type to “menu” in the dropdown menu and then click “OK”

Figure 2- Change the resource type to menuFigure 2: Change the resource type to menu 

Step 3:

Now you can see a new Android Resource Directory “menu” gets created,

Figure 3- Menu directory addedFigure 3: Menu directory added.PNG

Adding menu file in Menu Resource Directory

Step 1: To create menu file in menu folder, right click on “menu” directory, “New”, then click “Menu resource file“,

Figure 4- Add menu resource fileFigure 4: Add menu resource file

Step 2: Give the file name, menu_main.xml -> click Ok,

Figure 5- Naming menu resource menu_mainFigure 5: Naming menu resource file to "menu_main.xml"

Step 3: Now, you can see the directory structure, that shows the new file, “menu_main.xml” in “menu” directory.

Figure 6- menu_main file created in menu resource directoryFigure 6: menu directory structure

Here’s the video showing the above steps,



GW Editorial Staff

Editorial Staff at Generic Whiz.

Leave a Reply

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