Skip to content

Instantly share code, notes, and snippets.

@theonlyanil
Created February 24, 2018 12:48
Show Gist options
  • Save theonlyanil/d60d4a7736956dc7f790fd69b5360347 to your computer and use it in GitHub Desktop.
Save theonlyanil/d60d4a7736956dc7f790fd69b5360347 to your computer and use it in GitHub Desktop.
Endless Scrolling RecyclerView — Easiest Approach
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
...
// Load more - Endless Scrolling
if(position == this.getItemCount() - 1)
{
// Add a progress bar.
ProgressBar progressBar = new ProgressBar(context);
progressBar.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
linearLayout.addView(progressBar);
// add more
// Remove the progressbar.
Toast.makeText(getApplicationContext(), "Loading", Toast.LENGTH_SHORT).show();
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment