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.