title: android -How to load more items for recycleView on scroll
body: <p>I'm using recycle view , I'm getting data from net via json and use adapter to add items to my recycle view . I want to get new items when user reaches the end of the recycle view .</p>
  
  <p>I'm using GridLayoutManager for my recycle view . 
  this is the code :</p>
  
  <pre><code>    int pastVisiblesItems, visibleItemCount, totalItemCount;
      GridLayoutManager mLayoutManager;
      private boolean loading = true;
  
  recycle=(RecyclerView)findViewById(R.id.recycle);
          mLayoutManager = new GridLayoutManager(this, 3);
          // (Context context, int spanCount)
          recycle.setLayoutManager(mLayoutManager);
  
  recycle.addOnScrollListener(new RecyclerView.OnScrollListener() {
              @Override
              public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
  
                  visibleItemCount = mLayoutManager.getChildCount();
                  totalItemCount = mLayoutManager.getItemCount();
                  pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();
                  if (loadmore) {
                      if ((visibleItemCount + pastVisiblesItems) &gt;= totalItemCount) {
                          page = page + 1;
                          Toast.makeText(Cats.this, "test", Toast.LENGTH_SHORT);
                      }
                  }
              }
          });
  </code></pre>
  
  <p>I get to end of the recycleview but it doesn't show me any toast , so I think it doesn't understand that I reached the end of recycle view . </p>
  
  <p>What is wrong with this code ?</p>