2011-08-05 26 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> 

नीचे के रूप में पाद लेख है

यह अंतिम सूचीदृश्य आइटम के ठीक नीचे चला जाता है। मैं चाहता हूं कि पाद लेख नीचे हो। मैं इसे कैसे प्राप्त कर सकता हूं ??

पीएस: शीर्षलेख पूरी तरह से शीर्ष पर बैठता है।

आपके समय के लिए अग्रिम धन्यवाद।

+0

जहां सूचीदृश्य के लिए लेआउट है? – PravinCG

+0

मेरे पास एक अलग सूची दृश्य लेआउट नहीं है। मैंने ऊपर सूची सूची कोड दिया है और कोड में मैंने कोड को पुनः प्राप्त किया है। क्या एक लेआउट में सूचीदृश्य और हेडर फूअर शामिल करने और लागू करने का कोई तरीका है ?? कृपया मुझे स्पष्टीकरण दें। –

+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 के रूप में करने और इसके शीर्ष पर सूचीबद्ध करने की आवश्यकता है।

आह मैं एक और इसी तरह सवाल मिल गया है और जवाब भी एक ही :)

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" /> 
संबंधित मुद्दे