2013-07-24 5 views
4

У меня проблема с нижним колонтитулом для списка (я не могу сосредоточить нижний колонтитул).Ширина нижнего колонтитула ListView

Я использую нижний колонтитул для бесконечного списка.

Проблема, с которой я столкнулась, заключается в том, что нижний колонтитул не растягивается в соответствии с шириной списка (вместо этого используется как-то использование wrap_content).

Это сноска расположение:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/footer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" 
    android:gravity="center" 
    android:padding="10dp" > 

    <ProgressBar 
     android:id="@+id/progressBar" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_vertical" /> 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="5dp" 
     android:text="Loading more..." /> 

</LinearLayout> 

И это, как я добавить колонтитул в ListView:

View footerView; 

...  

// Get the custom layout for footer 
     footerView = getActivity().getLayoutInflater(). 
       inflate(R.layout.list_footer_load_more, getListView(), false); 
     LinearLayout footerViewLayout = (LinearLayout) footerView.findViewById(R.id.footer_layout); 
     // Adding custom view to ListView at footer 
     getListView().addFooterView(footerViewLayout, null, false); 

И это, как конечный результат выглядит следующим образом: (я могу 't размещать изображения в stackoverflow, но вот внешняя ссылка на изображение) http://s21.postimg.org/3zkd7pic7/listview_footer_problem.png

Я пробовал все, в нижнем колонтитуле, но ничего не получилось. Я надеюсь, что кто-то может мне помочь, потому что это вызывает у меня какое-то время.

спасибо.

ответ

3

Изменить футер раскладка (R.layout.list_footer_load_more) по адресу:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/footer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_horizontal" > 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

     <ProgressBar 
      android:id="@+id/progressBar" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" /> 

     <TextView 
      android:id="@+id/textView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:padding="5dp" 
      android:layout_gravity="center_vertical" 
      android:text="Loading more..." /> 

    </LinearLayout> 
</RelativeLayout> 

Изменить код:

View footerView; 

...  

// Get the custom layout for footer 
footerView = getActivity().getLayoutInflater(). 
      inflate(R.layout.list_footer_load_more, null); 
RelativeLayout footerViewLayout = (RelativeLayout) footerView.findViewById(R.id.footer_layout); 
    // Adding custom view to ListView at footer 
    getListView().addFooterView(footerViewLayout, null, false); 
+0

К сожалению, это все те же –

+0

@IonutNegru я изменил код немного , Посмотрите, работает ли это сейчас. – Vikram

+0

@IonutNegru И, раздувая 'R.id.footer_layout', используйте' inflate (R.layout.list_footer_load_more, null); ' – Vikram

Смежные вопросы