我想顯示其結構已在XML文件中定義的自定義警報對話框。這是我使用的代碼。未顯示自定義警報對話框
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(findViewById(R.layout.inputform));
builder.show();
單擊按鈕時會觸發。但是,該窗口未顯示。我在屏幕頂部獲得了這個透明的灰色圖層,無法點擊任何東西。不過,使用setMessage
或顯示覆選框的一些基本代碼很適用。任何人都可以指出我做錯了什麼?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="Room name" android:id="@+id/TextView01"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<EditText android:hint="Enter room name" android:id="@+id/EditText01"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_weight="1"/>
</TableRow>
<TableRow android:id="@+id/TableRow02" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="Point id" android:id="@+id/TextView02"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<EditText android:hint="Enter point id" android:id="@+id/EditText02"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_weight="1"/>
</TableRow>
<TableRow android:id="@+id/TableRow03" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:text="OK" android:id="@+id/btnOK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</LinearLayout>
你的對話框的XML代碼? – WarrenFaith 2011-01-28 12:48:18