2011-09-27 11 views
2

일부 콘텐츠가 포함 된 목록보기를 갖고 싶습니다. 그리고 그 아래에, 당신이 listview의 buttom으로 스크롤 할 때, 새로운 헤더 뷰가 표시되고 새로운리스트 뷰가 표시 될 것입니다. 가능합니까?목록보기 목록보기 android

// 편집 두 목록보기에는 differet 레이아웃 xml이 있어야합니다.

두 번째 listview를 첫 번째 footview에 넣으려고했습니다. 그러나 두 번째 목록보기는 작을 것입니다.

은 여기 내 레이아웃

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 

     <LinearLayout android:id="@+id/header" 
      android:background="@drawable/app_topbar" android:layout_width="fill_parent" 
      android:orientation="horizontal" android:layout_height="wrap_content" 
      android:layout_alignParentTop="true"> 

      <TextView android:text="@string/headline_notused" 
       android:gravity="center" android:textSize="24sp" android:textStyle="bold" 
       android:textColor="@color/txtcolor" android:layout_width="fill_parent" 
       android:layout_height="fill_parent"></TextView> 

     </LinearLayout> 

     <ProgressBar android:layout_width="fill_parent" 
      android:layout_height="wrap_content" android:layout_below="@+id/header" 
      android:visibility="gone" style="?android:attr/progressBarStyleHorizontal" 
      android:id="@+id/progressbarHorizontal" /> 

     <ListView android:id="@+id/notUsedList" android:divider="@android:color/transparent" 
      android:dividerHeight="5dip" android:layout_height="wrap_content" 
      android:layout_marginBottom="5dip" android:layout_width="fill_parent" 
      android:layout_weight="1" 
      android:layout_below="@+id/progressbarHorizontal"></ListView> 

     <LinearLayout android:orientation="vertical" 
      android:layout_below="@+id/notUsedList" android:background="@drawable/app_background" 
      android:layout_marginBottom="55dip" android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

      <LinearLayout android:id="@+id/myUsedHeader" 
       android:background="@drawable/app_topbar" android:layout_marginTop="10dip" 
       android:layout_width="fill_parent" android:orientation="horizontal" 
       android:layout_height="wrap_content" android:layout_alignParentTop="true"> 

       <TextView android:text="@string/headline_used" android:gravity="center" 
        android:textSize="24sp" android:textStyle="bold" android:textColor="@color/txtcolor" 
        android:layout_width="fill_parent" android:layout_height="fill_parent"></TextView> 

      </LinearLayout> 

      <ListView android:id="@+id/usedList" 
       android:divider="@android:color/transparent" android:dividerHeight="5dip" 
       android:layout_height="fill_parent" android:layout_width="fill_parent"></ListView> 

     </LinearLayout> 
</RelativeLayout> 
+0

어댑터를 초기화 할 때 목록 및 목록 항목의 레이아웃을 설정합니다. 나는 그 문제를 이해하지 못한다 ... 첫 번째 목록은 두 번째 항목과 아무 상관이 없다. – rf43

+0

귀하의 의견을 이해하지 못합니다 : 귀하의 목록보기를 새로운 것으로 바꾸거나 다른 행 레이아웃의 일부 항목을 추가하여 이전의 목록보기를 더 길게 만드시겠습니까? –

+0

행 레이아웃이 다른 일부 항목을 추가하여 이전 목록 뷰를 더 오랫동안 만들 수 있습니다. 또한 새 머리글을 추가해야합니다. 이해하기 어려운 경우 죄송합니다. – Casper

답변

2

다른 섹션과 각 섹션에 헤더가있는 listview를 의미합니다. 이 링크를 사용해보십시오 Jeff sharkey adapter

+0

두 개의 목록보기가 다른 레이아웃을 실행하도록 레이아웃을 변경할 수 있습니까? – Casper

+0

두 목록의 행이 다른 레이아웃을 가져야 함을 의미합니다. 물론 할 수 있습니다. – anujprashar

+0

나는이 작업장이 필요하다. 그래서 내가 필요로하는 곳이 하나있다. 그래서 그것은 굉장했다. 그러나 또 다른 활동에서 나는 또한 listview 뒤에 배경을 바꿀 필요가 있었다. 여기에 나는 첫 번째의 footerview에 두 번째 listview를 두는 것으로 끝났다. 그리고 나서 dp에 1 아이템 * arraylist.size()의 높이를 계산하는 배후에서 코드를 작성했다. 고맙습니다. – Casper

1

당신이 목록보기 마지막 항목에 도착하면 당신은 감지해야합니다.

는, OnScrollListener을 구현하여 ListViewonScrollListener하고 당신이 제대로 일을 처리 할 수 ​​있어야합니다 설정 :

그런 다음, 어댑터, 변경 활동 또는 wathever 새 목록보기 표시 할 적절한 찾을 수를 변경할 수 있습니다. 예를 들어

:

// Initialization stuff. 
yourListView.setOnScrollListener(this); 

// ... ... ... 

@Override 
public void onScroll(AbsListView lw, final int firstVisibleItem, 
       final int visibleItemCount, final int totalItemCount) { 

    switch(lw.getId()) { 
     case android.R.id.list:  

      final int lastItem = firstVisibleItem + visibleItemCount; 
      if(lastItem == totalItemCount) { 
       // Last item is fully visible. You will then need to start a New activity, maybe... Or change the layout.. I don't know! 
      } 
    } 
} 
+0

오케이, 레이아웃 xml도 바꿀 수 있습니까? – Casper

+0

물론, 어댑터를 변경해야합니다. 귀하의 응용 프로그램을 모르지만 개인적으로 새 Listview를 사용하여 새 Activity를 시작 하겠지만 ... 동일한 활동에 머물러야 할 필요가 있다면 getListView(). setAdapter (new YourAdapter (blabla)); –

+0

@casper : 모든 뉴스? 이게 효과가 있니? –

0

예 가능합니다. 하나의리스트 뷰를 linearlayout에 정의하고 onether를 다른 linearlayout에 정의하고 두 Listview를 부모 LinearLayout에 둘 수 있습니다.

+0

선형 배치가 필요합니까? 왜냐하면 지금 당장 스크롤 문제가 생겼어. 나는 또한 footview 안의 마지막 listview를 첫 번째 것에 넣으려고 노력하고있다. 그러나 그것은 작동하지 않는다. – Casper

+0

android : minHeight = "? android : attr/listPreferredItemHeight"이 속성을 listview 속성에서 사용하면 scrollview 문제를 해결할 수 있습니다. –

+0

두 목록보기에서 모두 사용할 수 있습니까? – Casper