4
我正在爲Android應用程序設計佈局。這是佈局的骨架。 無法將視圖投射到Android佈局中的ViewGroup中
我試過的是使用表格佈局,因爲GUI可以分解成表格行和列。 基本上,我想把佈局分成兩列,就像你看到的那樣。 下面是XML代碼
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- 2 columns -->
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" >
<View
android:id="@+id/view1"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:text="Column 1"
android:textAppearance="?android:attr/textAppearanceLarge" />
</View>
<View
android:id="@+id/view2"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:text="Column 2" />
</View>
</TableRow>
</TableLayout>
我得到的GUI
Exception raised during rendering: android.view.View cannot be cast to android.view.ViewGroup
下面的錯誤,我認爲這表示我們不能組的意見。如果不可能,該如何處理。我來自網頁背景。我以爲我可以使用視圖作爲像HTML一樣的div。