0

ダイアログに表示するデータを取得しようとしています。

ダイアログには、チェックボックスと 2 つのボタンが表示されるので、レイアウト ファイルが読み込まれていることがわかります。

他に何をすべきかわからないので、なぜダイアログの背景が完全に透明になるのでしょうか? さらに重要なことに、実験した 2 つのビューで何も見えないのはなぜですか?

ここに私のレイアウトファイル全体があります:

<?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が、同じ結果です。2 つのボタンのすぐ下にあるダイアログは透明です。

初期化が完了すると、 には 9 つの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();

ListViewとを使用してこれを試し、とArrayAdapterを拡張するカスタム アダプタを作成しました。ArrayAdapterBaseAdapter

と の背景を明示的ListViewTableLayoutColor.YELLOW に設定し、他の色を設定しようとしましたが、何も役に立ちません。

4

2 に答える 2

0

解決策:問題はLinearLayout、ボタンを含む が属性fill_parentの代わりに持っていることでしwrap_contentた。layout_height

于 2012-02-19T15:41:25.253 に答える
0

多くの場合、TableLayout は機能しません。さらに、アプリの実行中に TableLayout が問題を引き起こします。

常に LinearLayout または FrameLayout を使用することをお勧めします。

Linearlayout は、TableLayout を使用している任意の場所に収まります。

于 2012-02-19T10:52:58.930 に答える