2013-07-24 2 views
4

나는 목록보기를위한 꼬리말에 문제가있다. 나는 꼬리말을 가운데에 맞출 수 없다.ListView footer width

끝없는 목록으로 바닥 글을 사용하고 있습니다.

내가 겪고있는 문제는 꼬리표가 목록 너비와 일치하도록 (즉, 어떻게 든 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> 

그리고 이것은 내가 목록보기에 바닥 글을 추가하는 방법은 다음과 같습니다

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); 

그리고 이것은 최종 결과이 같은 모습입니다 stackoverflow에 이미지를 게시하지 않지만 여기 이미지의 외부 링크입니다) http://s21.postimg.org/3zkd7pic7/listview_footer_problem.png

나는 모든 것을 시도했습니다. r 바닥 글 하나도 효과가 없었습니다. 나는 누군가가 나를 도울 수 있기를 바라고있다.

감사합니다.

답변

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