1

Androidアプリ開発初心者です。

これは私の xml レイアウト ファイルです。

<?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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<Button 
    android:layout_weight="0.5"
    android:id="@+id/back"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/cancel"/>

<Button 
    android:layout_weight="0.5"
    android:layout_gravity="right"
    android:id="@+id/editall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/editall"/>
</LinearLayout>
<ListView 
    android:id="@android:id/list"
    android:cacheColorHint="#00000000"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:fadingEdge="none"/>
</LinearLayout>

これでボタンは表示されますが、リスト ビューは表示されません。どんな体でも助けてください。前もって感謝します

4

3 に答える 3

4

ボタンの線形レイアウトwrap_contentの代わりに置き換えるだけです。fill_parent

への変更

<?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" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button 
    android:layout_weight="0.5"
    android:id="@+id/back"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/cancel"/>

<Button 
    android:layout_weight="0.5"
    android:layout_gravity="right"
    android:id="@+id/editall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/editall"/>
</LinearLayout>
<ListView 
    android:id="@android:id/list"
    android:cacheColorHint="#00000000"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:fadingEdge="none"/>
</LinearLayout>
于 2012-07-16T12:08:41.100 に答える
0

あなたの にも を設定しましたAdapterか? コンテナに高さを適用して透明な背景を設定したため、空の場合は画面に何も表示されません。ListViewonCreate()cacheColorHintwrap_content

于 2012-07-16T12:40:20.860 に答える
0

内側の Linear Layout の高さを fill_parent から wrap_content に変更します。

高さ fill_parent を指定すると、リストビューを非表示にする親の高さ全体がカバーされるため

于 2012-07-16T12:16:00.467 に答える