2
我試圖創建一個標題欄是在我的應用程序相同,並已對我的每一個活動,創建這樣的佈局:使用多種佈局與包括標籤Android中
的main.xml:
<?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">
<include layout="@layout/title_bar_layout" android:id="@+id/title_bar_layout" />
<include layout="@layout/main_body" android:id="@+id/main_body" />
</LinearLayout>
main_body.xml:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_table" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:stretchColumns="1"
android:orientation="vertical">
</TableLayout>
我的onCreate包含:
setContentView(R.layout.main);
TableLayout t = (TableLayout) findViewById(R.id.main_table);
但t總是以null結尾。
在您的例子主要佈局文件被稱爲「主」,但你用「日程」的setContentView。有鏈接嗎?如果不是,請檢查相同佈局中是否沒有其他id/main_table元素。 – Jean 2010-10-19 03:36:04
其實我的問題只是一個錯字,抱歉!編輯它以反映我的意思。 – powerj1984 2010-10-19 03:37:50