I made an Android layout file recently, and it worked like normal with being able to edit it via the text and design tabs.
Then, I don't know what I did, but the text in the file got grayed out, the android ui icon went away where the files are listed on the left hand side, and I can't call them from inside my Java code. What can I do to convert these files back to Android layout files? Cleaning and rebuilding doesn't work.
You can't put layout files into subfolders, that's why they're not working.
Move them out of the subfolder and into the main folder and they will work again.
Related
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
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.
I'm fairly new to eclipse and android development, and I'm having what must be a pretty simple error to fix. I've done some development on my laptop and never encountered these errors. (I currently only have access to public computers, and have eclipse and the SDK installed on a USB drive.)
The first strange thing I noticed when editing the main layout was that there is no properties window to allow easy editing of various layouts and objects. (There was on my old computer) I have not been able to figure out how to get this window to appear.
So after adding one textView and modifying its properties by hand, I receive the following two errors when I attempt to run the program. (No code has even been added yet, just one textView)
http://i.stack.imgur.com/9VGT0.png (Link to screenshot of error, only have 6 rep)
All I've done is change the textView to have center gravity, fill_parent layout width, and a textSize of 22sp. I've tried googling the errors to figure out what I'm doing wrong but have been unsuccessful. Anybody encounter this before? Also, if anybody knows how to make the properties window appear it would be a great help.
Thanks in advance
When compiling Android stuff in Eclipse, you have to press the "Run" button with a .java file open, not with .xml file open. No idea why, but the glitch is there and you'll soon remember to avoid it.
To fix the current state, delete the 'main.out.xml' file (it was automatically created on compile). Then in the 'Problems' tab (the one on your screenshot), manually delete each problem it shows you. After that, press Run again with a .java file open and it should solve whatever is there now.
You get the properties window back from the "Show View" dialog, which is accessible from the "Window" -> "Show View" -> "Other ..." menu.
Once the dialog is open, look in the "General" folder for "Properties".
right click the .xml file and go to Open With... there are many ways to open it. I prefer the xml editor but there is also a layout editor available.
Your XML is not well-formed, e.g. mismatched elements, mismatched quotes, etc. Show your XML for more specific assistance.
I thought ADT should come with a visual editor for building GUI : Easy way to build Android UI?
However, I just cannot find it. I was wondering where is the Visual Editor for Eclipse with the ADT plugin.
I can run HelloWorld application without problem. However, whenever I click on main.xml at the left navigation tree layout folder, here is what I get. What I wish to get is a WYSIWYG editor.
Select your main.xml file. At the bottom of eclipse you can see a Layout tab, click on it and eclipse will open the android gui editor.
As Paul Kearny previously noted, to resolve issue with seeing "Design" tab instead of "Graphical Layout" follow these 2 steps:
1) Delete project from the left of the screen, without deleting the source files
2) File -> Import -> Existing Projects into Workspace, browse and select your workspace folder and open your project
Graphical Layout problem fixed!
If you want to edit the layout visually, rather than through XML, click on the Layout tab at the bottom left of the main.xml window (in your screenshot, just above Problems).
Also note, there are issues with displaying some of the widgets. For example, the ListView does not render. So, my hint is to change ListView to just a View, then work out the details of the layout so you can get the colors, relative-ness, etc. Then switch it back to ListView. There is one other widget that I cannot recall off the top of my head ...
To resolve issue with seeing "Design" tab instead of "Layout" or "Graphic Layout", I had to:
1. Delete the project from Eclipse without deleting the source
2. Shut down and restart Eclipse
3. Import the project back in
You could probably skip step 2, but I did it just to make sure.
Hope this helps anyone else who has the same issue.
If your view is showing Design|Source for the .xml file right click on the main.xml and select open with - android common XML editor. Simple.
If it is happening to one particular xml, you can delete the file (make sure you copy the content first), create new xml and paste the content again.
I recommend that any serious Android developer stay far, far away from Eclipse/ADT Design View. This is a time-wasting tool that sorely lacks the attention it would need from Google to make it worth serious consideration. It doesn't render the views as a real device would. There is no way to bind dynamic data. Does it work with fragments (I think not)? For it to work properly and have useful features would weigh down Eclipse further and make it unacceptably slow. In my very humble opinion, the entire strategy for ADT's ui-design tools has failed.
Thus, the recommendation is: edit Android XML layout files by hand and use the only reliable testing mechanism you have for layouts: actual devices. You can always fallback on the emulator - but the emulator performs 50x - 100x slower than an actual device. I'm not exaggerating. Pick your poison!
new fix, took me forever to get this fixed, really simple....delete the xml file and undo the deletion (ctrl+z), double click and there you go. Hope this helps someone as it did me. No shut down required.
If you see "Design" tab instead of "Graphical layout", just close the project and open it again.
While developing for Android, I am unable to open more than one main.xml file in an Eclipse editor at a time. Each time I open one, it simply replaces the editor (tab) of the first main.xml with the new one, instead of opening a new tab - even if the contents of the existing tab were unsaved!
Even stranger, I can open multiple main.xml files from different projects with no problems. This only happens when they're within the same project.
Any idea how to fix or work around this? It's a real time-waster.
(Running Eclipse Classic 3.5.2 64bit w/ADT 0.9.7 on Win7 Home Premium x64)
Edit for clarity:
It's not the same file opened twice. In one project, there is a file called "main.xml" in a directory called "Layout". There is another file also called "main.xml" in a directory called "Layout-Land". These two files cannot be opened at the same time. I'm not sure if this is a problem with Eclipse or with ADT.
More info:
For kicks I created two new files in those same directories (both called "item.txt") and they both opened properly (each in their own tab). I renamed them both to "item.xml" and tried opening them again, and sure enough they fought for the same tab. This leads me to believe ADT is at fault since xml files in these layout directories are opened with ADT's layout tool. I could be wrong though.
Right click on main.mxl and choose 'new editor'- this will create another main.xml which you can replace with the landscape version via a double click.
However, eclipse does this for a reason- so you don't get confused and bork your files up.
I would think you also could edit these files in a text editor to the side with little loss of efficiency.
This is because the two different files represent the same layout just in different configurations. If you want to edit the landscape layout you have to click on the 'Layout' tab at the bottom of the editor and select the 'Config' that you want to edit. Depending on the configuration you select you'll have the layout xml editor fill with the correct contents from each file.