main.xml file not found - android

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.

Related

Unable to jump to particular xml file using layout inspector in android studio

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.

Lost EVERYTHING in my Android app in Eclipse?

I closed the main.xml Layout file in Eclipse, and all of the sudden, this is what I get:
No XML content. Please add a root view or layout to your document
All of the xml code is gone, the Graphic Layout editor is gone, and I can't get anything back. I lost the whole project. I'm in Eclipse 3.7.
I really need help with this. It has done this to EVERY Android project I've ever created. I can't finish an app. I get 2 activities done, then Eclipse bones me with this screen again.
may be the xml dont save, you can try this:
right click the xml file -> compare with - > local history
in the local history to find right content

Android XML editors broken in Eclipse

Until today (I have no idea what I did to cause this), if I double-clicked an android XML file, then the correct editor would appear.
For example, double-clicking a layout file would open a Graphical Layout tab and a tab with the XML contents for direct editing (named as the file being edited). Now all I get is a Design and a Source tab!
I am unable to preview the layouts I am editing (this is the same as here: Graphical Layout tab does not appear for some layout files into Eclipse)
That link also gives a 'workaround' in that I can right-click the file and open with the right editor, but this isn't a solution!
How can I sort this permenantly? I have re-installed fresh Eclipse, ADT to no avail (haven't used fresh SDK... will that matter??).
** Note this happens to all Android XML files, not just layout ones I mentioned above! **
Yes this may be a permanent solution:
Select any XML layout file
click on Window->Preferences menu.
Follow steps as mentioned in attached image.
What I had to end up doing was selecting the Legacy Android Xml Resources Editor from the same list that Paresh is showing and setting it as the default. I had to choose it from the list that appears when you click the add button. After that I restarted eclipse and everything was fine.

setContentView problem

I am beginner in android so some beginer problems is occured. I create second activiy and second layout xml file named getNearest.xml. The code section to show this file is
setContentView(R.layout.getNearest)
But eclipse cannot be find getNearest. It only shows .main. So what is the problem with this?
You need to build at least once to have the R.layout values updated when you create a new layout. Also make sure you saved the layout file and that it exists under the res\layout folder.

Unable to add Preferences.xml (Android Preferences in XML)

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).

Categories

Resources