How to implement infinite scroll with RecyclerView in Android using Parse

前端 未结 1 1211
灰色年华
灰色年华 2021-01-03 13:27

Most of the articles I found online used setLimit function to load more items. But it is not an efficient way as we would be recalling the existing objects.

I\'m usi

相关标签:
1条回答
  • 2021-01-03 13:54

    Finally I solved it by using setSkip function.

    Code:

    private int limit =0; 
    private boolean loadMore = false;  
    
    
    
    ParseQuery<ParseObject> query = ParseQuery.getQuery("ClassName");
    
    if(loadMore==true)
        {
            query.setSkip(limit); 
            query.setLimit(12);
        } 
        else
        {
            query.setLimit(12); 
        }
    
    query.findInBackground(new FindCallback<ParseObject>() 
         {
    
            @Override
            public void done(List<ParseObject> arg0, ParseException arg1) 
            { 
                limit = limit+ arg0.size(); 
    
                if(arg0.size()==0)
                {
                    loadMore = false; 
                }
                else
                {
                    loadMore = true; 
                }
    
            });
    
    0 讨论(0)
提交回复
热议问题