can't edit specific xml file in Eclipse - android

There are similar questions, but none address my specific issue.
I'm rather new to Android development and Eclipse but was able to follow the tutorials A OK.
In fact, I'm able to edit activity_main.xml from a tutorial, but now, in a test project I'm working on, I can't edit my new activity_main.xml (again, different project, same filename).
I created the file by right-clicking on the layout folder then selecting NEW > OTHER > Android XML Layout File. I was able to copy some of the other file so that my file now looks essentially like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
</LinearLayout>
When I type, the cursor moves around (looping through the text) but no characters appear on the screen. Again, in the other XML file I can edit with no problem.
I'm hoping that this is just some newbie problem.

I have had similar problems, though not this exact problem. Sometimes simply restarting Eclipse, or whatever editor you use, can help. Occasionally, Eclipse will not detect changes in your xml so you need to clean and rebuild the project. You can do this by
Winodow --> Project --> Clean...
and choose your project
I know there was an issue that I had which was similar with the editor jumping/replacing lines and such which I believe was fixed in a newer version of Eclipse. If I can find a source later I will edit

Clear all of text in layout activity_main.xml (in code view)
Drag and drop new LinearLayout in layout (in graphical view)
Go to Project -> Clean

Related

Prevent android studio to create more than a tag in xml files

In the new android studio 3.3 or 3.2 if we create a for example button auto generate create a text like
<Button android:layout_width="" android:layout_height=""/>
but I would like something more like this
<Button
android:layout_width=""
android:layout_height=""/>
like old versions of Android studio is there a setting or something for that?
That is related to XML code wrapping. By default it should be on wrap always but maybe it's not in your Android Studio or they changed that in newer versions. Anyway you can find that by click on:
Preferences -> Code Style (expand it) -> XML -> Android(Tab) ->
Here you can find Layout Files and below options like: Wrap always, Don't wrap, Wrap if long etc. So set it on Wrap always and Apply changes and your XML code from now on should be wrapped.
It hints something that says reduce intent with 4 spaces. Try to configure that :)
Or use the hard way by pressing enter for the new row.

How to fix error: The schemas property will be ignored because your document does not declare any matching target namespaces

Using Visual Studio 2015 - Xamarin Android
When I hover over the LinearLayout element of one of my axml files, I get this warning
"The schemas property will be ignored because your document does not
declare any matching target namespaces."
When I right click on the xml file and choose properties it shows 2 schemas selected.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">...
The 2 schemas are
C:\Source\MobileApp\test\MyApp\obj\Debug\Schemas\21\android-layout-xml.xsd C:\Source\MobileApp\test\MyApp\obj\Debug\Schemas\21\schemas.android.com.apk.res.android.xsd
I changed my app name above, for this post but kept the rest intact.
I don't get what it's asking for.
I created a new app and I'm not getting that error.
The only difference I can see is the new app references folder \23\ and not \21.
I tried removing the 21 folder and replacing it with the one from my test app and it just recreates it.
It almost feels like intellisense for Xamarin was never added.
Thanks ahead of time for any and all help.

Android Studio: 'wrap in container' in XML layout

When editing XML layout files, Eclipse has a feature called 'wrap in container' (Reformat -> Android -> ...) that lets you select one or several Views and wrap a layout of your choice around it.
Is there something similar in Android Studio?
It's currently being implemented:
Issue 69000: Add the "Wrap In" visual refactoring - Android Issue Tracker
Tor Norbye, Android Issue Tracker Mantainer:
We should implement the "Wrap In" visual refactoring.
Just came across this, and to complete Simas' answer:
using AS1.2, this is easy to achieve...
to set up a Live Template, simply select the View in your layout XML
that you wanna surround. Hit Alt+Shift+Z (surround-with)... a little
popup appears. Click Configure Live Templates.... Or use File->Settings->Editor->Live Templates as described above.
Select the html/xml section and hit the little +. Give it a name and description, then fill in template text:
<LinearLayout
android:orientation="$ORIENTATION$"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
$SELECTION$
</LinearLayout>
Click Edit variables, set Expression:complete(), Default value:vertical... hit OK. Then, find the Define' button for applicable context... and select XML.
You're all set now. To use the template, select the View that you wanna surround in the XML, hit Alt+Shift+Z (surround-with)... a little popup appears. Select the template you just defined... Done!
You can use Live Templates for that. Here's a nice article about them.
Edit:
New templates can be added through File->Settings->Editor->Live Templates.
To find the hotkey for your keymap go to File->Settings and write "Live template". For me it's CTRL + J .

Graphical Layout missing for xml layout file Android

I have opened up a android project but the xml file graphical layout is not being shown..I have searched on stack overflow and found that it can be fixed by clicking create in top right ..but it is greyed out and does not come up...even if i fill all the details of locale,editing config,change android API level to 2.2/3.0 ..The file opens in xml view..Screenshots are attached..
Can anyone let me know what is the problem and its solution.
If the answer is there somewhere on stack overflow..kindly provide the link..i will delete the question..i wasn't able to find the answer myself..
Open With > Android Common XML editor will not work.
The two tabs was missing because of the theme. Try to set your theme back to the default one. Eclipse > Preferences > General > Appearance > Theme combobox > Mac

Eclipse + ADT - Autocomplete in #string/ references in layout files

When I am editing a layout file is there a way to get eclipse to autocomplete my strings references from strings.xml.
For example if I have a layout node like this...
<PreferenceCategory android:title="#string/settings_category_stay_intouch_title">
It would be great if I could type the #string/settings_ part and then use alt+space like I can when I referencing the R.string in a source file.
Right now I just get "No XML Template Proposal"
Any tips for configuration or plugins would be appreciated. I use strings.xml extensively and I have a ton of layout files so flipping back and forth between strings.xml and my layouts as I work on them is a bummer.
Well it should work. Try using on windows CTL+space.
I tested with latest ADT 16.

Categories

Resources