Saturday, 15 August 2015

android - How to add a button at the end of RecyclerView? -


I want to show a button at the end of the RecyclerView.

There was a method addFooterView with ListView (), how to do the same with RecylerView.

"itemprop =" text ">

In a way it will be done to make your footer" View Typ "of your adapter In order to do this, getItemViewType overrides to give a different value for your last item.

  @Override public integer getItemViewType (integer status) {return (position == mData.size ())? VIEW_TYPE_FOOTER: VIEW_TYPE_CELL; }  

Then onCreateViewHolder, handle different viewType.

@Override Public RecyclerView.ViewHolder onCreateViewHolder (ViewGroup parent, integer viewType) {if (viewType == VIEW_TYPE_CELL) {// Create viewholder for your default cell} else {// your foot To view the article, create the viewholder}}

Do not forget to update the price refund by getCount (by adding 1), and to separate the 2 type of viewholder in the Onbandviewholder (eg With example)


No comments:

Post a Comment