2011-08-05 15 views
6

Mam ListView jak poniżejAndroid: stopka w ListView

<?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="horizontal" 
    android:background="#E6E7E2"> 
    <ImageView android:id="@+id/Thumbnail" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:src="@drawable/icon" /> 
    <TextView android:id="@+id/FilePath" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="#E6E7E2" 
     /> 
</LinearLayout> 

i mam stopki jak poniżej

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" android:layout_gravity="bottom"> 
    <LinearLayout android:layout_width="fill_parent" 
      android:layout_alignParentBottom="true" 
      android:layout_height="wrap_content" 
      android:id="@+id/layoutfooterbutton" android:layout_gravity="bottom"> 

      <Button android:layout_weight=".30" android:layout_margin="2dp" 
       android:layout_height="60dp" android:layout_width="100dp" 
       android:textColor="#FFF" android:gravity="bottom|center" 
       android:textSize="12dp" android:id="@+id/ButtonAudio" android:background="@drawable/vid_red"/> 

      <Button android:layout_weight=".30" android:layout_height="60dp" android:layout_width="100dp" 
       android:gravity="bottom|center" android:background="@drawable/redblank" 
       android:textColor="#E6E7E2" android:id="@+id/ButtonBrowse" android:layout_marginTop="2dp"/> 
      <Button android:layout_weight=".30" android:layout_margin="2dp" 
       android:layout_height="60dp" android:layout_width="100dp" 
       android:textColor="#FFF" android:gravity="bottom|center" 
       android:textSize="12dp" android:background="@drawable/reddelete" android:id="@+id/ButtonDelete"/> 

     </LinearLayout> 
</RelativeLayout> 

Kiedy dodać stopkę do ListView przy użyciu

View header = getLayoutInflater().inflate(R.layout.header, null); 
View footer = getLayoutInflater().inflate(R.layout.footer, null); 
ListView lv = getListView(); 

// setting header for the list view 
lv.addHeaderView(header); 
lv.addFooterView(footer); 
setListAdapter(new ArrayAdapter<String>(AudioListActivity.this, R.layout.row_audio, R.id.label, db_results)); 

Powoduje przejście bezpośrednio pod ostatni element listy. Chcę, żeby stopka znajdowała się na dole. Jak mogę to osiągnąć?

PS: Nagłówek idealnie leży na górze.

dzięki za twój czas z góry.

+0

gdzie jest układ dla ListView? – PravinCG

+0

Nie mam osobnego układu ListView. Podałem powyższy kod listview iw kodzie otrzymałem kod. czy istnieje sposób uwzględnienia listview i nagłówka fooer w jednym układzie i implementacji? Proszę, wyjaśnij mi. –

+0

Ten [LINK] (http://blog.maxaller.name/2010/05/attaching-a-sticky-headerfooter-to-an-android-listview/) ma doskonały przykład, wystarczy spojrzeć ... również do kasy to pytanie ... [wśród nas] (http://stackoverflow.com/questions/6121186/android-listview-with-header-and-footer-buttons) – Hanry

Odpowiedz

6

dla scenariusza myślę, że trzeba coś podobnego do tego.

<RelativeLayout> 
    <include android:id="@+id/header" layout="@layout/header" android:layout_width="fill_parent" android:layout_alignParentTop="true" /> 

    <include android:id="@+id/footer" layout="@layout/footer" android:layout_width="fill_parent" android:layout_alignParentBottom="true" /> 

    <ListView android:layout_below="@id/header" android:layout_above="@id/footer"/> 
</RelativeLayout> 
3

Działa zgodnie z przeznaczeniem. Widok stopki znajdzie się u dołu listy. Jeśli chcesz mieć coś statycznego u dołu ekranu, powinieneś użyć RelativeLayout ze stopką jako alignParentBottom i umieścić na górze listy.

Ahh znalazłem innej podobnej pytanie, a odpowiedź jest taka sama :)

Android ListView Footer View not being placed on the bottom of the screen

+0

które nie pomogło eitehr :( –

+0

co zrobiłeś i co teraz robisz? – PravinCG

+0

Zmieniłem górny układ stopki jako układ listview, wciąż taki sam, nic się nie zmieniło.Nie chcę, aby stopka została naprawiona na dole.Nie wydaje się, że można to osiągnąć przez Androida –

0

Spróbuj ..

<ListView 
     android:id="@+id/your_id" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     tools:listfooter="@layout/your_layout" />