The first is the main layout
<android.support.v4.widget.swiperefreshlayoutxmlns:android= "Http://schemas.android.com/apk/res/android" Android:id= "@+id/swiperefreshlayout" android:layout_width= "match_parent" android:layout_height= "Match_parent" > <android.support.v7.widget.recyclerview android:id= "@+id/recylerview" android:layout_width= "Wrap_ Content "android:layout_height=" Wrap_content "></android.support.v7.widget.recyclerview></ Android.support.v4.widget.swiperefreshlayout>
Then get the control and set the listener
findviewbyid......// Set drop-down refresh Swiperefreshlayout.setonrefreshlistener (New swiperefreshlayout.onrefreshlistener () { @Override public void onrefresh () { if ( isrefreshing) {//Determine if you are refreshing &NBSP;&NBSP;LOG.D (TAG, "ignore manually update!") ; } else{ do....... } } });
said pull refresh, then there are pull-up loads more, In fact, I think the pull-up load more recyclerview and swiperefreshlayout have not done very well, but also this control is not very comfortable place. A simple way to introduce
Recyclerview.setonscrolllistener (New recyclerview.onscrolllistener () { @Override public void onscrolled (Recyclerview recyclerview, int dx, int dy) { super.onscrolled (Recyclerview, dx, dy); int lastVisibleItem = ((Linearlayoutmanager) Mlayoutmanager). Findlastvisibleitemposition (); int totalitemcount = mlayoutmanager.getitemcount (); //lastvisibleitem >= totalitemcount - 4 means that the remaining 4 item is loaded automatically, and you are free to choose // dy>0 means swipe down if (lastvisibleitem >= totalitemcount - 4 && dy > 0) { if (Isloadingmore) { &NBSP;&NBSP;&NBSP;LOG.D (TAG, "ignore manually update!"); } else{ loadpagE ();//Here The multithreading also need to manually control the isloadingmore isLoadingMore = false; } } } } );
Summarize:
1, the new control is very comfortable to use, but a lot of features are not all written well
2, expect the official solution pull load more problems
The simple use of Android Recyclerview