2011-08-05 8 views
6

に私はアンドロイド:フッターの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> 

以下のようにリストビューを持っていると私は

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)); 
を使用してリストビューにフッターを追加すると、私は

<?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> 

以下のようにフッターを持っています

最後のリストビュー項目のすぐ下に移動します。私はフッターが底に来るようにしたい。どのように私はそれを達成することができますか?

PS:ヘッダーが完全に上に座っています。

お時間をいただきありがとうございます。

+0

? – PravinCG

+0

私は別のListViewレイアウトを持っていません。私は上記のlistviewコードを与えて、コードで私はコードをretreived。 1つのレイアウトにlistviewとheader fooerを含める方法がありますか?私を明確にしてください。 –

+0

この[LInk](http://blog.maxaller.name/2010/05/attaching-a-sticky-headerfooter-to-an-android-listview/)には完璧な例があります。この質問... [私たちの間](http://stackoverflow.com/questions/6121186/android-listview-with-header-and-footer-buttons) – Hanry

答えて

6

である私はあなたがこれに似た何かが必​​要だと思います。

<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

これは意図したとおりに動作しています。フッタービューはリストの一番下に表示されます。画面の一番下に何か静的なものを置いておきたい場合は、フッタにalignParentBottomというRelativeLayoutを使用し、その上にリストを表示する必要があります。

ああ、私は別の同様の質問を発見し、答えはまたあなたのシナリオの同じ:)

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

+0

これは助けになりませんでしたeitehr :( –

+0

あなたは何をしましたか? – PravinCG

+0

フッターのトップレイアウトをリストビューレイアウトに変更しましたが、変更はありません。フッターを下に固定したいと思っています。 –

0

試してみてください、この...リストビューのレイアウトがある

<ListView 
     android:id="@+id/your_id" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     tools:listfooter="@layout/your_layout" /> 
関連する問題