2017-01-02 4 views
0

목록에 10 개의 요소를 한꺼번에 표시해야한다는 요구 사항이 있습니다. 10 개의 요소를로드 한 후 사용자는 "더 많은 결과로드"버튼을 갖게됩니다. 이 버튼을 클릭하면 서버에서 다른 10 개의 요소를 가져옵니다. 처음에는 전체 번호. 요소의 수가 10 개 미만이면 "결과 더보기"버튼이 표시되지 않아야합니다.Recycler보기 "결과 더보기"단추

그래서 Recycler View를 사용하여 이것을 개발하고 싶습니다. 그러나 이것을 할 수는 없습니다. 나를 안내하십시오. 사전에

감사

+2

' "하지만 난이 할 수 아니다"'그래서 당신이 지금까지 시도? – pskink

+0

먼저 배열리스트에 10 개의 항목을 추가하십시오. Load More Results를 클릭하면 배열 목록에 10 개의 항목이 더 추가되고, adapter.notifyDataSetChanged()가 수행됩니다. – Redman

+0

@Redman 귀하의 제안에 감사드립니다 –

답변

0

xml에서 loadButton 표시 여부를 변경했습니다. 활동 클래스에서

API 콜백 메소드의 어댑터로 설정 데이터, 그냥

if(list.size()>=10) { 
    loadButton.setVisibility(VISIBLE); 
    } else { 
    loadButton.setVisibility(GONE); 
    } 
+0

감사합니다. 대답 –

+0

문제가 해결되면 정답으로 표시 @AbdulRahaman –

0

RecyclerView.OnScrollListener

첫째는 recyclerview에 OnScrollListener를 구현합니다. 스크롤 리스너에서 마지막 항목을 가져 와서 LOAD MORE 버튼을 넣을 수 있습니다. 마지막 항목이 RecyclerView 일 때 표시합니다.

+0

감사합니다. –

+0

@Vikas –

0

를 확인이 같은 시작할 수 있습니다.

<android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <android.support.v7.widget.RecyclerView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:nestedScrollingEnabled="false" /> 

      <Button 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Load More" 
       android:visibility="visible" /> 

     </LinearLayout> 


    </android.support.v4.widget.NestedScrollView> 

까지 당신 구현 로직)

관련 문제