how do you create a res/menu folder with a main.xml when a res/layout has a main.xml file
In the project tab of left pane, select the res folder and Control+click to open context menu. Then, New > Android Resouce Directory.
Just name it menu for the directory name. And click ok.
Now you got res/menu, select it and Control+click to open context menu. Then, New > Menu Resource File.
Input your menu resource file's name (ex. main).
At last you can get res/menu/main.xml.
Related
Problem:
layout XML folder is missing?
How to add it?
If the folder isn't there or wasn't added automatically when you created the project, you need to add it to your project in the following way:
Right-click on the res folder
Select New -> Android Resource Directory from the menu that opens
Select Resource type to be layout from the popup that opens
Click ok
Now you have added your layout folder, so you can now start adding XML files to this folder by the following steps:
Right-click on the layout folder
Select New -> Layout Resource File from the menu that opens
Enter your new file name
Click ok
Now you have a new XML file that you can use in any activity or fragment.
After open the layout resource file and which new file name, can be typed
According to the Android Studio first app tutorial, there should be a folder in the res called layout folder and inside that folder > activity_my.xml file.
My res folder does not contain the layout folder, it has drawable, mipmap, and value folders.
I have attempted restarting the program and creating multiple new projects.
Right click on resource folder and create new directory with layout name and put your xml in it . i hope your problem solved .
Right click on res folder and create new directory with layout name and put ur XML in it . hope ur problem solved .
Don't create in drawable folder , create in res folder or another way is to cut your layout directory and paste in res folder
I'm a very new programmer in Android. I'm trying to define an action overflow button in my app. From what I've read it involves modifying the menu.xml file.
I cannot find that file in my app and I don't have the res > menu directory.
I have created a SettingActivity. Any Suggestions?
You can create a menu dir in the res/ folder. Right click on res in the project view in Android Studio and click new -> "Android Resource Directory". Then select menu under "Resource Type". You can then add a file to that new res/menu directory that contains your menu items like this (res/menu/main_menu.xml)
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/action"
android:title="#string/action"
app:showAsAction="always" />
</menu>
And get sure to override the onCreateOptionsMenu(Menu menu) in the MainActivity class like this:
#Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu,menu);
return true;
}
Right click on res and you will android resource directory ->give directory name ->give resource type as menu : a menu folder will be created inside res, now right click on menu->new-> menu resource file->file name-> ok . Now you see the menu xml file inside res/menu/yourfile.xml
just change the "android" to "project" in the top right-hand side of the android studio software.
Right Click on the res in the Tools Window ->Select the Show in Explorer option.
If you have already created a menu directory and if it is hidden(or not shown) in the Tools Window, you can find it here.
If you have not created menu directory, you can use the the above answers to create it and add resource files to it.
Sometime when you create a menu resource directory then also it won't appear in the Android project view but it actually there, Since if it doesn't contain any file then the project indexing automatically hides it so to see that you just need to change from Android to Project Source files like.
This answer may not be helpful to you but maybe for others who may experience the same type of problem.
I have this custom xml file. I would parse it later.
The problem is where to put it. I used eclipse adt.
I created a new folder in the resources. I named it "xml".
After that i tried to create a XML file in the folder.
Right clicked the xml folder>new>android xml file
Then the window pops. I change the folder to res/xml but when I clicked the finish button nothing happens. Can you help me with this? Thanks.
Clean all your projects.
Update your ADT.
If its not the layout file, place it in asset folder
<AppName>/assets/
If you create android xml then that should be created in layout folder and extends any of android layout or controls.
For creating custom xml file, right click on res/xml folder --> new --> file and enter your filename.xml
Don't forget to add extention .xml
this might sound silly. i am trying to do tab layout for android.
there is a part where i need to create a drawable folder and have android xml file in that particular folder.
i have looked into all the tutorial and youtube for this. The tutorial shows create a new android xml file and choose Drawable for the type of the resources.
in my case, i cannot create new android xml file with Drawable as the type of resources as Drawable does not exist. Below shows the interface.
is there anyway can help me with this? i also tried to add the resource manually but it wont work.
if i am creating a new android xml file with other resource type and force it to put in drawable folder, the application crash.
1. Go to your project explorer which should be on the left side of your eclipse IDE.
2. Right click the res folder of your project
3. Click new, then folder
4. Name that folder drawable
5. Right click your new drawable folder, click new
6. Search for XML File in the XML folder
7. ENJOY :)
I'm not sure if i understand exactly what you mean, Is this what you want to do? If so then the steps provided is how to do so, if you need me to clarify let me know.
Do the following,
your project -> new -> Folder -> write drawable in the text box -> finish
So, drawable folder is now created in res folder.
Then,
drawable -> new -> File -> enter the name of the xml file you want to create (ex. test.xml)
OR
drawable -> new -> Android XML File -> enter the name of the xml file you want to create (ex. test)
Now you can see there is a .xml file in your drawable folder. Now you do whatever you like to do with this .xml file.
#Sara if you have successfully created your extra "drawable" folder, right click on the new "drawable" folder and go to new Android XML File, just name the new xml file and finish next.