开发者

Android XML not well formed

开发者 https://www.devze.com 2023-03-16 18:08 出处:网络
\'<?xml version=\"1.0\" encoding=\"utf-8\"?> <TableLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
'<?xml version="1.0" encoding="utf-8"?>
 <TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout开发者_运维百科_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/droid_background"
>
 <TextView  
android:layout_height="wrap_content" 
android:gravity="center_horizontal"
android:text="@string/hello"
android:textColor="#FFFFFF"
android:textStyle="bold"
>
<RelativeLayout>
<ToggleButton
android:id="@+id/togglebutton1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Audio"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" 
>
</RelativeLayout>
</TableLayout>'

Getting error XML parsing: not well formed between The opening <ToggleButton> and closing </RelativeLayout>. What am I doing wrong?


you are missing closing tags or / on TextView & ToggleButton


You don't appear to have closing tags for the <TextView> and <ToggleButton>.

You would benefit from spending a bit of time reading about basic XML document structure. In particular, XML needs to be well-formed. Here's a good tutorial:

http://www.javacommerce.com/displaypage.jsp?name=wellform.sql&id=18238


<?xml version="1.0" encoding="utf-8"?>  
<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/droid_background" >  
    <TextView   
        android:layout_height="wrap_content"  
        android:gravity="center_horizontal" 
        android:text="@string/hello" 
        android:textColor="#FFFFFF" 
        android:textStyle="bold" /> 
    <LinearLayout
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" > 
        <ToggleButton 
            android:id="@+id/togglebutton1" 
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:text="Audio" 
            android:layout_alignParentRight="true" 
            android:layout_alignParentBottom="true"  /> 
    </LinearLayout> 
</TableLayout>


Assuming you don't mean to have the quotes there, you need to end your TextViews and Toggle Butotns.

Try to look here: http://developer.android.com/guide/topics/ui/declaring-layout.html

Change your code to this:

<?xml version="1.0" encoding="utf-8"?>
 <TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/droid_background"
>
 <TextView  
android:layout_height="wrap_content" 
android:gravity="center_horizontal"
android:text="@string/hello"
android:textColor="#FFFFFF"
android:textStyle="bold"
 />
<RelativeLayout>
<ToggleButton
android:id="@+id/togglebutton1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Audio"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" 
 />
</RelativeLayout>
</TableLayout>


You didn't closed ToggleButton and TextView tag. Take attention to that always. Thats common mistake use

    <ToggleButton /> 

instead.


'<?xml version="1.0" encoding="utf-8"?>
 <TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/droid_background" >
 <TextView  
android:layout_height="wrap_content" 
android:gravity="center_horizontal"
android:text="@string/hello"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<RelativeLayout
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
<ToggleButton
android:id="@+id/togglebutton1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Audio"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</TableLayout>'

your relative layout must have height and width properties


you should close the balise ToggleButton , there is two ways to do it :

<ToggleButton......... > </ToggleButton> OR <ToggleButton ........./>

the same thing for the TextView , so verify all of your views when coding :)

Regards


replace your toggle code with that (ie close it) and add a closing for the text view () depending on what is nested inside the textview.

0

精彩评论

暂无评论...
验证码 换一张
取 消