0

リストビューがあります。

フッターを追加したい。

だから私はフッターxmlを作成します

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="100px"
android:background="@drawable/background_news_list"
android:gravity="center" >

<ImageButton
    android:id="@+id/btn_more"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="10px"
    android:background="@drawable/btn_more_news" />

</LinearLayout>

レイアウト全体をメインのJavaに膨張させたいのですが、ボタンのみを膨張させることができます

footer = getLayoutInflater().inflate(R.layout.testing, null, false);
btnmore = (ImageButton)footer.findViewById(R.id.btn_more);

ListView lv = (ListView) findViewById(android.R.id.list);
lv.addFooterView(footer);

私のリストはこのxmlにあります

<LinearLayout
    android:id="@+id/layout_content"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@id/layout_menu"
    android:layout_below="@id/layout_title"
    android:orientation="vertical" >

    <ListView
        android:id="@+android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </ListView>
</LinearLayout>

ビューグループを作成してこのようになるにはどうすればよいですか?

footer = getLayoutInflater().inflate(R.layout.testing, parent, false);

独自の線形レイアウトを使用できるようにします。

4

2 に答える 2

0

私はこれを行うことによってそれを解決しました

footer = getLayoutInflater().inflate(R.layout.testing, lv, false);

それの訳は

lv is the list id and it 
于 2012-05-10T01:58:32.620 に答える
0

あなたの投稿は少し紛らわしいですが、LinearLayoutにIDを追加する必要があると思います。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@id/linlayoutid"
    android:layout_width="fill_parent"
    android:layout_height="100px"
    android:background="@drawable/background_news_list"
    android:gravity="center" >

<ImageButton
    android:id="@+id/btn_more"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="10px"
    android:background="@drawable/btn_more_news" />

</LinearLayout>

次に、線形レイアウトを取得します。

footer = getLayoutInflater().inflate(R.layout.testing, null, false);
LinearLayout ll = footer.findViewById(R.id.linlayoutid);

ListView lv = (ListView) findViewById(android.R.id.list);
lv.addFooterView(ll);
于 2012-05-09T15:12:05.963 に答える