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. GsmCellLocation.getCid() returns very large numbers.

Sorry for bringing up this topic from the past, but I was wondering if
the OP or anyone else knows the cause or a solution to this problem

I'm to get the LAC:CID on the G1 (android 1.6) and it always
returning larger than allowed (ffff is max allowed) numbers (or -1).

I get the exact same numbers whether I use getCid() from
GsmCellLocation or use onCellLocationChanged() from PhoneStateListener


Any guidance would be appreciated

On Mar 26 2009, 9:17am, Richard Schilling


2. Playlist Content Provider

I'm making a media player, but my code doesn't show all my playlists
and for many others it does not show any...
Why doesn't the code below work completely?

cursor = getContentResolver().query(
        null, null, null, null);


3. looking for android 1.0 or 0.9 source

4. Device Seeding -- a sad story

5. Got my free DROID, who's paying for service?

6. android-gdocs-api

7. Fastest and most reliable Location provider