【发布时间】:2011-06-17 05:34:46
【问题描述】:
我想显示一个自定义警报对话框,其结构已在 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>
【问题讨论】:
标签: android android-alertdialog