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.

menu resource directory

What we will learn?

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

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”,

Add Android resource directory:

Add-Android-resource-directory

Step 2:

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

Change the resource type to menu:

Change-the-resource-type-to-menu-

Step 3:

Now you can see a new Android Resource Directory ā€œmenuā€ gets created,

Menu directory added:

Menu directory added

Adding menu file in Menu Resource Directory
(res/menu/menu_main.xml)

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

Add menu resource file:

Add-menu-resource-file

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

Naming menu resource file to “menu_main.xml

Naming menu resource menu_main

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

Menu Directory Structure:

menu_main file created in menu resource directory

Here’s the video showing the above steps,


If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


For Videos, Join Our YouTube Channel: Join Now


Padding in Android Layout
Top 100 Android Interview Questions and Answers
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading