我一直在尝试让一些数据显示在我的对话框中。
在对话框中,我有一个复选框和两个按钮显示,所以我知道它正在加载我的布局文件。
我不确定还能做什么,那么为什么我的对话框上的背景会完全透明,更重要的是,为什么我在我尝试过的两个视图中看不到任何东西?
这是我的整个布局文件:
<?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"
android:orientation="vertical" >
<CheckBox
android:id="@+id/show_all_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Include books read" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/books_by_author_select_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Books" />
<Button
android:id="@+id/books_by_author_cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel" />
</LinearLayout>
<TableLayout android:id="@+id/books_by_author_list" 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>
</LinearLayout>
我也试过这个,ListView
但结果相同。在这两个按钮的正下方,对话框是透明的。
当TableLayout
它完成初始化时有九个孩子,因为它没有出现,所以我TableRow
在上面的 xml 中添加了,最初那个块不存在。
this.mContext = context;
setContentView(R.layout.books_by_author);
final TableLayout view = (TableLayout) findViewById(R.id.books_by_author_list);
for(int position = 0; position < list.size(); position++) {
TableLayout table = (TableLayout) findViewById(R.id.books_by_author_list);
// create a new TableRow
TableRow row = new TableRow(mContext);
// create a new TextView
TextView t = new TextView(mContext);
// set the text to "text xx"
t.setText(list.get(position).mTitle);
// create a CheckBox
CheckBox c = new CheckBox(mContext);
// add the TextView and the CheckBox to the new TableRow
row.addView(t);
row.addView(c);
// add the TableRow to the TableLayout
table.addView(row,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
view.invalidate();
我已经尝试过使用 aListView
并且只使用了ArrayAdapter
,并且我创建了一个自定义适配器扩展ArrayAdapter
和BaseAdapter
。
我还明确将 and 的背景设置ListView
为TableLayout
Color.YELLOW,并尝试设置其他颜色,但没有任何帮助。