Skip to content Skip to sidebar Skip to footer

Change The View Text Of Footer Itemview Of Recyclerview

Hi I have a condition where I have to add different viewType with text show more or loading... at the bottom of the recyclerview I have successfully added the footer view with sho

Solution 1:

Can you try disabling the footer view button once the user clicks on it?

funenableShowMore(enable: Boolean) {
        if( enable ) {
            itemView.btnShowMore.text = "show more"
        } else {
            itemView.btnShowMore.text = "loading..."
        }
        itemView.btnShowMore.isEnabled = enable
    }

Update :

//In the adapter
mIsFooterEnabled = false//In the View holder funenableShowMore() {
  if( mIsFooterEnabled ) {
      itemView.btnShowMore.text = "show more"    
  } else {
      itemView.btnShowMore.text = "loading..."  
  }
  itemView.btnShowMore.isEnabled = mIsFooterEnabled
}

//In your activity / fragmentprivatefunenableShowMore(enable: Boolean) {
    adapter.mIsFooterEnabled = enable
    adapter.notifyDataSetChanged()
}

Solution 2:

Could you please try to put your function code inside enableShowMore() in onBindViewHolder() or set holder.bind for FooterViewHolder and put code inside binder function.

Let me know if it is useful or not.

Post a Comment for "Change The View Text Of Footer Itemview Of Recyclerview"