2016-08-03 10 views
-1
rlDetail.addOnScrollListener(new RecyclerView.OnScrollListener() { 
     @Override 
     public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 
      if (dy > 0) //check for scroll down 
      { 
       visibleItemCount = mLayoutManager.getChildCount(); 
       VLogger.infoLog("visibleItemCount" + visibleItemCount + ""); 
       totalItemCount = mLayoutManager.getItemCount(); 
       VLogger.infoLog("totalItemCount" + totalItemCount + ""); 
       pastVisiblesItems =  mLayoutManager.findFirstVisibleItemPosition(); 
       VLogger.infoLog("pastVisiblesItems" + pastVisiblesItems + ""); 

       if (loading) { 
        if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) { 
         page_no = page_no + 1; 
         msgList(); 
         VLogger.infoLog("...", "Last Item Wow !"); 
        } 
       } 
      } 
     } 
    }); 

私はアンドロイドグリッド表示

答えて

1
girdview.setOnScrollListener(new AbsListView.OnScrollListener() { 
      @Override 
      public void onScrollStateChanged(AbsListView absListView, int scrollState) { 
       // Pause fetcher to ensure smoother scrolling when flinging // You can ignore this part 
       if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) { 
        mImageFetcher.setPauseWork(true); 
       } else { 
        mImageFetcher.setPauseWork(false); 
       } 
      } 

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

       final int _lastItem = firstVisibleItem + visibleItemCount; 
       if (_lastItem > 0 && totalItemCount > 0) 
        if (_lastItem == albums.size() && !endOfAlbums && lastItem != _lastItem) { 
         lastItem = _lastItem; 
         // Last item is fully visible. 
         loadAlbums(); 
        } 
      } 
     }); 

     return view; 
    } 

    private void loadAlbums() { 

     if (currentPage == 0) { 
      albums.clear(); 
      endOfAlbums = false; 
      lastItem = 0; 
      // get new releases 
      progressLayout.setVisibility(View.VISIBLE); 
     } else 
      progressLoadMore.setVisibility(View.VISIBLE); 

     if (Utility.isNetworkAvailable(getActivity())) { 

      new Thread(new Runnable() { 
       @Override 
       public void run() { 

        // get the serverAlbums 
        ArrayList<Album> serverAlbums = ServerAPI.getAllAlbums(session.getLanguage(), currentPage); 
        if (serverAlbums.size() > 0) 
         albums.addAll(serverAlbums); 
        else 
         endOfAlbums = true; 

        currentPage++; 

        myHandler.post(updateRunnable); 
       } 
      }).start(); 
      updateRunnable = new Runnable() { 
       @Override 
       public void run() { 

        if (albums.size() > 0) { 

         imageAdapter.notifyDataSetChanged(); 
         // get listview current position - used to maintain scroll position 
         int currentPosition = girdview.getFirstVisiblePosition(); 

         // Setting new scroll position 
         girdview.smoothScrollToPosition(currentPosition + 1, 0); 
        } else 
         tvNoAlbums.setVisibility(View.VISIBLE); 

        progressLayout.setVisibility(View.GONE); 
        progressLoadMore.setVisibility(View.GONE); 
       } 
      }; 
     } else { 
      Toast.makeText(getActivity(), R.string.check_connectivity, Toast.LENGTH_SHORT).show(); 
      progressLayout.setVisibility(View.GONE); 
      progressLoadMore.setVisibility(View.GONE); 
     } 

    } 

でグリッドビューでは上記のように行うことができ、それは仕事がためだincrement.howページでスクロールコール同じWebサービス上のグリッド表示私はこれを試してください

関連する問題