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. ViewGroup#onInterceptTouchEvent is only called once

In my custom ViewGroup, I am returning false after handling the
MotionEvent.ACTION_DOWN event.

According to the javadoc:

For as long as you return false from this function, each following
event (up to and including the final up) will be delivered first here
and then to the target's onTouchEvent().

However, I notice that all subsequent events ( MotionEvent.ACTION_MOVE
and MotionEvent.ACTION_UP) are only
delivered to my #onTouchEvent method. In #onTouchEvent , I always
return true.

What could possibly be my bug ? I am running on Android 1.5r2 SDK.

Thanks a lot




2. Doc and Samples typos and suggestions?


I've found a couple of typos in the dev guide and samples.

Does anyone know how to pass these onto the Google Android doc team?


3. Flash for android

4. Now ADC2 judging has begun.

5. Turn on and turn off Synchronization with Gmail,

6. app Wavesecure

7. Gtalk, Sharing YM id, lagiii...