Tengo una vista de lista.
Quiero agregar pie de página.
Entonces creo un pie de página 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>
Quiero inflar todo el diseño en Java principal pero logro inflar solo el botón
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);
mi lista está en este 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>
¿Cómo creo un grupo de visualización para cumplir y ser así?
footer = getLayoutInflater().inflate(R.layout.testing, parent, false);
Para poder usar mi propio diseño lineal.
Respuestas
0 para la respuesta № 1Su publicación es un poco confusa, pero creo que solo necesita agregar una identificación a su LinearLayout:
<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>
Luego toma el diseño lineal:
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);
0 para la respuesta № 2
Lo resolví haciendo esto
footer = getLayoutInflater().inflate(R.layout.testing, lv, false);
Esto es porque
lv is the list id and it