What is wrong with this layout

by idev » Wed, 04 Mar 2009 23:50:36 GMT

Sponsored Links
 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" http://schemas.android.com/apk/res/ 
    android:text="@string/hello" >
    <Button android:id="@+id/installRing"


I cannot understand what is wrong with this layout. I keep getting
this error in the xml saying Element type "Button" must be either
followed by attributes or > or />
I don't understand why the editor can't recognize android:id as an
attribute! I tried writing the whole XML again but keep getting this

Thanks for any help.


What is wrong with this layout

by Stoyan Damov » Thu, 05 Mar 2009 00:40:41 GMT

 Not quite sure (haven't looked at the schema) but perhaps Button is an
empty element, so in your layout it should look like this:

That is, close the element " />" and remove the "</Button>" element end.



Sponsored Links

What is wrong with this layout

by Streets Of Boston » Thu, 05 Mar 2009 06:01:31 GMT

 The XML in your post is ok. I just pasted it into an XML editor and it
validates OK.

However, this is what i've seen in Eclipse as well when editing XML
files for my android projects, especially XML files for layout in
Eclipse's layout-editor plugin for Android.

Sometimes an error is reported when there is none. And most of the
time i could get rid of the error by removing whitespace and re-adding
it; e.g. by deleting a new-line and replacing it by a space. It has me
puzzled... i suspect there is something going on with the white-space
handling of the layout-plugin that handles XML files. Maybe Cr+Lf
versus just Lf, i don't know....


What is wrong with this layout

by iDeveloper » Thu, 05 Mar 2009 11:46:41 GMT


But AFAIK having a close button tag and closing the tag using /> is  
one and the same!


What is wrong with this layout

by Streets Of Boston » Fri, 06 Mar 2009 06:35:15 GMT

 Yep, but not quite: :=)


is the same as


But <button/> is not the same as


because here the button-element has child text-node containing

But then again, in your layout-xml it should not matter. This
whitespace should just be ignored.


What is wrong with this layout

by Marco Nelissen » Fri, 06 Mar 2009 06:40:56 GMT

 That layout compiles fine for me. Are you sure you don't have some
non-printable character in your xml file that is messing things up?


What is wrong with this layout

by iDeveloper » Fri, 06 Mar 2009 12:43:36 GMT

 Yeah that was it. COpied it into notepad and it showed some garbled up  
things. Thanks.


Other Threads

1. The MultiBubbles Online tournament has started. Win prizes while playing MultiBubbles on your Android device!

Hello Android users,

As you may know, the Android Developer Challenge 2 started several
days ago. The stakes are high and the competition is tough. We, the
creators of MultiBubbles, decided to take a different approach to
promote our application and we hope that you are going to enjoy it. We
are starting an online tournament and the best MultiBubbles players
are going to get some nice prizes.

WIN UP TO $250 WHILE PLAYING MultiBubbles Online!

For more info: http://multibubbles.com/news/multibubbles_online_tournament/

2. DDMS won't load (or doesn't parse?) KML file

Thnkkkkkkkkkkkk you,,really very thanks to you :)),,
Ultimately  It worked fine


3. Getting the user's own email address

4. You must supply a resource ID for a TextView

5. Andriod and Arabic language

6. Webview control is not worked!!!!!

7. Android on Samsung touch phone