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"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bkg"
    >
    <TextView
    android:layout_width="fill_parent"
    android:layout_height="200px"
    android:text="@string/hello" >
    </TextView>
    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="55px"
    android:gravity="center">
    <Button android:id="@+id/installRing"
    android:layout_width="wrap_content"
    android:layout_height="52px"
    android:background="@drawable/installBtn">
        </Button>
    </LinearLayout>

</LinearLayout>

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
error!

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.

HTH,
Stoyan




--~--~---------~--~----~------------~-------~--~----~


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


 Thanks.

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: :=)

    <button></button>

is the same as

    <button/>


But <button/> is not the same as

   <button>
   </button>

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

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. Please help in getting screen coordinates of a view

Hi Jark,

Here is my code

package com.android.table;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.graphics.Rect;

public class GameDemo extends Activity {
        public static int idLayout = 1;
        public static int screenheight = 0;
        public static int screenwidth = 0;
        public AddPegHoles adp = new AddPegHoles(this);
        public Hole h;
        public static int holeid = 0;
        Hole[] holeArray = new Hole[33];
        FrameLayout l1,l2,l3,l4,;
        RelativeLayout layout;
        /** Called when the activity is first created. */
        @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        layout=(RelativeLayout) findViewById(R.id.tableviewback);
        layout.setBackgroundResource(R.drawable.woodenbackground);

        Display display;
        display =
((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
        screenheight = display.getHeight();
        screenwidth = display.getWidth();

        l1=(FrameLayout)findViewById(R.id.frame1);
        adp.addPegHoles(l1, 1,0);
        createHole(holeid,true,R.id.frame1,1);
        l2=(FrameLayout)findViewById(R.id.frame2);
        adp.addPegHoles(l2, 1, leftpadding+l1.getWidth());
        holeid++;       createHole(holeid,true,R.id.frame2,1);
        l3=(FrameLayout)findViewById(R.id.frame3);
        adp.addPegHoles(l3, 1, leftpadding+l1.getWidth());
        holeid++;       createHole(holeid,true,R.id.frame3,1);


        int  leftpadding=(screenwidth/7);
        int  toppadding=(screenheight/7);




On Mon, Mar 23, 2009 at 5:28 PM, Jark Reijerink



--~--~---------~--~----~------------~-------~--~----~

2. How can my application be intimated whenever i edit my contact list

Hi group,
I need to generate an xml file every time  for the details in the
contact list when there is a new addition or when i edit my contact
list .Is there any listener available to invoke a callback method
when  changes happen to my contact list?
Thanks

--~--~---------~--~----~------------~-------~--~----~

3. Issue in android:duration in frame animation

4. Is Android browser supports Content-Encoding : gzip ???

5. How can an app own two langues (English and German)

6. Why so many force closes?

7. Do you think Android apps will ever sell 100,000+ copies?