For example, if I had something like
setContentView(R.layout.activity_main);
Would there be a shortcut to open activity_main.xml? If not, is there a way to create one?
Its there. Just hold Ctrl and move the cursor to the word activity_main which is the line setContentView(R.layout.activity_main); then, it will be give two option that one is for opening xml layout and another one is opening the declaration in R.java file. This is the shortcut to open the XML layout easily.
Cheers!
This is not exactly a shortcut, but you can highlight the activity_main part on that setContentView(R.layout.activity_main); line and then press Ctrl+Shift+R.
The Open Resource dialog that shows up should have activity_main.xml (along with other files with activity_main in their names) at the top of the list. Just press Enter to open the one you want.
Actually its an id. When you create an XML file in android automatically that file has given an id by Android and you can find it into gen folder and the class name is R.java. So if you want to see that file you have to open res folder -> layout folder -> there you can see that xml file.
But you can do it as #joe or #Spk has suggested you. And Spk's solution is far better. So cheers.
if you have the class file opened instead of the java file it probably wont work. But in the java file press control on windows or command on mac and hover over the element for options to navigate.
Related
I am working on a multi-module application that has hundreds of XML layout files. Many of these files have duplicate or similar id's. I am trying to navigate to a specific screen layout file by using the Layout Inspector in Android Studio, but when I click on the "id" attribute, I do not see a link to the corresponding XML file. Instead, I see "unknown:?" displayed. Additionally, when I try to find the specific XML file using the "Find in Path" feature in Android Studio, I am unable to locate it. How can I navigate to a specific screen layout file in this scenario?
Clicking on the
Search Everywhere
Icon at the top-right, if I write
*.xml
in the search row and click on the
Files
tab, then I'm able to see all the xml files.
I am a beginner in android and I am learning it by watching tutorials on YouTube. I completed all the initial steps for building up an android project but I am unable to find out any main.xml file or activity_main.xml file under res/layout folder. In fact, the layout folder is not even showing any drop down menu. I googled my doubts but I am unable to find any satisfactory answer. Can someone please tell me what exactly went wrong ?
Add your own activity_main.xml file to the layout folder. Right click layout -> New -> Android XML File -> Name the file activity_main and click Finish.
At least if you have the MainActivy.class file, (the launcher activity), the ide, wheater android studio or eclipse should show you if the you layout activity exist by underlining the parameters for the 'setcontentlayout()' function if it doesnt exist. The 'setoptionsmenu()' function also do the same. if they are there, your MainActivity.class should be free from errors otherwise create them and insert them.
my Android xml fle Design look like this.
but i want to view like this so how can do this?
Right click on xml and select open with -> Android XML Resources Editor and also
you can try open with -> Android Layout Editor to have Design Layout tab.
I also faced this problem earlier for all xml files but not for manifest file ,now it resolved
in my application our requirement is When the orientation of the activity changes place the appropriate land folder and xml files.in that we give wrong naming conventions for the layout folders instead of layout-land,layout-land-hdpi,layout-land-mdpi,layout-land-ldpi,layout-port,layout-port-hdpi,layout-port-mdpi,layout-port-ldpi when ever we correct the naming conventions it comes normally.
I want to create one new xml file in the drawable_hdpi folder, but the new file doesn't appears in the drawable_hdpi folder, it appears in the layout folder. Can you tell me why?
In SDK 1.6 it is OK, but in SDK 2.2 it is not.
edit:for example in the app res/drawable_hdpi choice the drawable_hdpi folder,then right-hand button create new android xml as foo.xml,but the xml is created at the layout_hdpi folder
not at the rawable_hdpi folder
My guess is that you are trying to create a new "Android XML" file in Eclipse by right-clicking on your drawable_hdpi folder. I am able to duplicate the problem you are having. The dialog that pops up when you try to do this can dictate where the file gets created based on various setting within.
I tried to embed and image here to show you but SO wouldn't let me. Sorry.
The radio buttons will change the folder list beneath the "Available Qualifiers" list will change depending on which button you select. For whatever reason, there is no radio button for drawable. If you try to edit the folder by hand, your radio button selection disappears and the finish button disables, so you can't even force it to do what you want.
Really you should just copy an xml file similar to what you want to your drawable_hdpi folder manually outside of eclipse. Afterwards, just do a refresh on your res folder in Eclipse and the file will show up there. Then you should be able to edit it within Eclipse.
Hope that helps,
Craig
Hopefully, this is a newbie question with a quick answer...
I am attempting to add a simple preferences file in a new Android project (New -> Android XML File), but it doesn't appear to be working correctly.
There is no root element to choose from when I select the Preference type layout. If I press Finish, it doesn't do anything. See screenshot below.
Thanks,
wTs
Just create a normal xml file to the project /res/xml/ folder and add your content to the file as usual. Should work just great. Eclipse detects it as a preference file once you have added the preference-xml and saved it.
You don't need to have a root element in the selection screen. Just replace whatever eclipse generates with what you want.
try refreshing the folder that the file is supposed to be in (in your example res/xml).