Skip to content Skip to sidebar Skip to footer

Recyclerviewpagination Endless Infinite Scrolling Issue

I am trying to implement Endless Infinite Scrolling with RecyclerView, but I am only getting all records and even not getting any progress while trying to scroll at bottom. this is

Solution 1:

Change getViewType like this if you want get progress bar at the end of list while calling API

@OverridepublicintgetItemViewType(int position){
    return (position >= newsList.size()) ? VIEW_PROG : VIEW_ITEM ;
}

And Add one to size to show progress

 @Override
    publicintgetItemCount() {
        return newsList.size() + 1;
    }

@Override
publicvoidonBindViewHolder(RecyclerView.ViewHolder holder,int position){
    if (newsList.get(position)!=null && getItemViewType(position)==VIEW_ITEM ) {

        final News single_news= (News) newsList.get(position);

        ((MyViewHolder) holder).title.setText(single_news.getTitle());

        ((MyViewHolder) holder).desc.setText(single_news.getDesc());

        ((MyViewHolder) holder).nextArrowimage.setImageResource(R.drawable.nextblackbutton);

        context = ((MyViewHolder) holder).image.getContext();

        Picasso.with(context).load("http://bitstobyte.in/upload/"+single_news.getImage()).placeholder(R.drawable.ic_favorite_white_24dp).error(R.drawable.ic_map_24dp).resize(100,100).into(((MyViewHolder) holder).image);

        ((MyViewHolder) holder).news= single_news;

    } else {
        ((ProgressViewHolder) holder).progressBar.setIndeterminate(true);
    }
}

Post a Comment for "Recyclerviewpagination Endless Infinite Scrolling Issue"