Android Recyclerview Add pull up load more features _android

Source: Internet
Author: User

The previous article has introduced how to add Footview for Recyclerview, and on this basis, the ability to add a page load is already very simple.
Previous post address: Add Footview and Headview for Recyclerview

Effect: (source code at the end of the article)

Achieve key

On the basis of the previous code, you simply add a certain modification to the Onbindviewholder (viewholder holder, int position) function, as follows:

@Override public
 void Onbindviewholder (viewholder holder, int position) {
  //Set up Viewholder to associate with the data
  LOG.D ("Xjj", getitemviewtype (position) + "");
  If Footview exists, and the current position ViewType is Foot_type if
  (Isfootview && (getitemviewtype (position) = Foot_type)) {
   Holder.tvFootView.setText (footviewtext);
   Refresh too fast so use hanlder delay two seconds
   Handler Handler = new Handler ();
   Handler.postdelayed (New Runnable () {
    @Override public
    void Run () {
     max_count = 5;
     Notifydatasetchanged ();
    }

  else {
   Holder.tvViewHolder.setText (mdata.get (position) + position);
  }
 

In the function, first let the item display "in Load ..." ", then use handler, delay two seconds to refresh, the logical content is mainly two, one is to display the maximum capacity increase 5, the second is to refresh the content of adapter.

Expand extension

The author here in order to make readers easy to understand, the use of a lot of places is more coarse, the reader is really used when it will not be so simple, here are listed several points for the reader to learn by themselves:
1, Footview is generally not just a textview, the UI has a certain pursuit of the reader needs to add at least one ProgressBar.
2, adapter content will not be directly used in the list, need to get from the network, and so refresh the content of the adapter generally need to use the thread, rather than a simple handler here can be.

SOURCE Address: Http://xiazai.jb51.net/201610/yuanma/PullRecyclerView (jb51.net). rar

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.