Categories
Android

error: Error parsing XML: no element found

This error is cause by some layout such as listview and scrolview can only be a unique child layout .

Scroll view 不可以和其他组件一起的作为子组件,就是说必须为上机布局的唯一子布局,解决方法是用一个单独的layout包裹Scroll View

[cce lang=”xml”]<?xml version=”1.0″ encoding=”utf-8″?>

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent” >

<Button
android:id=”@+id/Button01″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Add row” >
</Button>

<LinearLayout
android:layout_width=”fill_parent”
android:layout_height=”fill_parent” >

<ScrollView
android:id=”@+id/ScrollView01″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” >

<TableLayout
android:id=”@+id/TableLayout01″
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:stretchColumns=”0″ >

<TableRow
android:id=”@+id/TableRow01″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” >

<TextView
android:id=”@+id/TextView01″
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”textfield 1-1″ >
</TextView>

<CheckBox
android:id=”@+id/CheckBox01″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” >
</CheckBox>
</TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>

</LinearLayout>

[/cce]

Leave a Reply

Your email address will not be published. Required fields are marked *