2017-04-12 1 views
1

안녕하세요 친구를 결합 여부를 내 코드Recycleview 페이지 매김 내가 너무 아래에있는 내 recycleview에 페이지 매김을 통합하려는 어댑터 안드로이드

onCreateVIew에서

LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity()); 
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.task_recycle); 
    mRecyclerView.setHasFixedSize(true); 
    mRecyclerView.setLayoutManager(mLayoutManager); 
mRecyclerView.setOnScrollListener(new EndlessRecyclerOnScrollListener(mLayoutManager) { 
      @Override 
      public void onLoadMore(int current_page) { 
       if (OnzupApplication.mPendingDatas.size() < total) { 
        page++; 
        new getPendingTask(false,true).execute(); 

       } 
      } 

     }); 

if (mAllMethods.check_Internet() == true) { 
     new getPendingTask(true,false).execute(); 
    } else { 
     mAllMethods.ShowDialog(getActivity(), "", getString(R.string.net_not_available), "OK"); 
    } 

전화 AsyncTask를

public class getPendingTask extends AsyncTask<Void, Void, Void> { 

    private boolean showLoading; 
    boolean pagination; 

    public getPendingTask(boolean showLoading,boolean page) { 
     this.showLoading = showLoading; 
     this.pagination=page; 
    } 

    @Override 
    protected void onPreExecute() { 
     super.onPreExecute(); 
     if (showLoading == true) { 
      mProgressDialog = ProgressDialog.show(getActivity(), "", getString(R.string.loading)); 

     } 
    } 

    @Override 
    protected Void doInBackground(Void... voids) { 
     mGetPendigTask = (GetAllPendigTask) mPostParseGet.getPendingTask(mGetPendigTask, token, page); 
     return null; 
    } 

    @Override 
    protected void onPostExecute(Void aVoid) { 
     super.onPostExecute(aVoid); 
     if (showLoading == true) { 
      if (mProgressDialog != null) { 
       mProgressDialog.dismiss(); 
      } 
     } 

     try { 
      if (mPostParseGet.isNetError) { 
       mAllMethods.ShowNoConnectionDialog(mActivity, mContext, "", getString(R.string.net_not_available), getString(R.string.setting), getString(R.string.cancel)); 
      } else if (mPostParseGet.isOtherError) { 
       if (!mPostParseGet.isRequestTimeOutError) { 
        new ActivityHelper(mActivity).sendMail(token); 
       } 
       mAllMethods.ShowDialog(mActivity, "", getString(R.string.data_not_found), "OK"); 
      } else { 
       if (mGetPendigTask.isSuccess() == true) { 
        mPendingDatas = getData(); 


        total = Integer.parseInt(mGetPendigTask.getTotalitems()); 

        if (mGetPendigTask.getTasks().size() > 0) { 
         mTextViewNoData.setVisibility(View.GONE); 
         mRecyclerView.setVisibility(View.VISIBLE); 
         mAllPendingRecyclerAdapter = new AllPendingRecyclerAdapter(getActivity(), OnzupApplication.mPendingDatas); 
         if (pagination==false) 
         { 
          mRecyclerView.setAdapter(mAllPendingRecyclerAdapter); 
         } 
         mAllPendingRecyclerAdapter.notifyDataSetChanged(); 
        } else { 
         mTextViewNoData.setVisibility(View.VISIBLE); 
         mRecyclerView.setVisibility(View.GONE); 
        } 

       } 
      } 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 

    } 
} 

위의 코드를 호출하면 1 페이지가로드되지만 두 번째 페이지를 스크롤 할 때 내가 어떻게 해결할 수 있는지 전혀 모르겠다. 이 때문에 라인

mAllPendingRecyclerAdapter = new AllPendingRecyclerAdapter(getActivity(), OnzupApplication.mPendingDatas); 

당신이 처음에 어댑터를 생성 한의

답변

0

, 당신이 recyclerview에 용지를 더 기능을 사용하십시오. 새 어댑터를 만드는 대신 자신의 어댑터에 데이터를 추가해야합니다.