Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have
RecyclerView.Adapter<RecyclerView.ViewHolder>
with pagination button(Load More)
Load More button in RecyclerView like Footer. Each request get 20 rows and if I get <20 items I need disable this button:
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ViewHolder) {
} else if (holder instanceof FooterViewHolder) {
viewHolder.loadMore.setEnabled(isVisibleLoadButton);
public void addData(List<TransactionItem> opcTransactions) {
final int positionStart = transactionItems.size()+1;
isVisibleLoadButton = opcTransactions.size() >= 20;
transactionItems.addAll(opcTransactions);
notifyItemRangeInserted(positionStart, opcTransactions.size());
If I get opcTransactions with 1 or more items isVisibleLoadButton set false and my load More button set disable. But If I get emty list opcTransactions size = 0 - load More button not diasbled.
@Override
public int getItemCount() {
if (transactionItems == null) {
return 0;
if (transactionItems.size() == 0) {
//Return 1 here to show nothing
return 1;
// Add extra view to show the footer view
return transactionItems.size() + 1;
positionStart should point to last item of your list . and indexing starts form ZERO. Use it as .
final int positionStart = transactionItems.size();
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.