Superswiperefreshlayout
A powerful custom pull-down refresh component.
Why?
Pull down to refresh the control, presumably we use too much, such as the use of a lot of xlistview and so on. Recently, many of the listings in the project were implemented using Reyclerview instead of the original ListView, which was challenged by the original dropdown refresh method. Google's swiperefreshlayout has been able to meet most of the needs. However, because of its poor customization, the style of the dropdown refresh cannot be modified, and the nested view cannot follow the swipe of the finger. Based on the above considerations, customize your own powerful superswiperefreshlayout.
Feature
- Non-intrusive, no effect on the original ListView, Recyclerview, usage and swiperefreshlayout similar.
- You can customize the style of the head view, call the Setheaderview method to
- Support MORE: Recyclerview,listview,scrollview,gridview and so on.
- Included view (Recyclerview,listview etc) can slide with the slide of the finger
The default is to follow the slide of the finger and slide, can also be set to do not follow: Settargetscrollwithlayout (False)
- Callback Methods more
For example: Onrefresh () onpulldistance (int distance) and onpullenable (Boolean enable)
Developers can make a series of animations based on the values of distance in the drop-down process.
How to Usestep 1
<net.mobctrl.views.SuperSwipeRefreshLayoutandroid:id="@+id/swipe_refresh" android:layout_width="Match_parent"android:layout_height="Match_parent" > <android.support.v7.widget.RecyclerViewandroid:id="@+id/recycler_view" android:layout_width="Match_parent"android:layout_height="Match_parent" /> </net.mobctrl.views.SuperSwipeRefreshLayout>
Step 2
Swiperefreshlayout = (superswiperefreshlayout) Findviewbyid (R.id.swipe_refresh); Swiperefreshlayout.setheaderview (Createheaderview ());//Add HeaderviewSwiperefreshlayout. Setonpullrefreshlistener (NewOnpullrefreshlistener () {@Override Public void Onrefresh() {//todo Start Refresh}@Override Public void onpulldistance(intDistance) {//todo drop-down distance}@Override Public void onpullenable(BooleanEnable) {//todo drop-down is sufficient to set the distance to refresh} });
Step 3
swipeRefreshLayout.setHeaderView(createHeaderView());// add headerView/** * create Header View */privatecreateHeaderView(){ //TODO 创建下拉刷新头部的View样式}
Sliding settings with hand
- Settargetscrollwithlayout (false/true);//default true
swipeRefreshLayout.setTargetScrollWithLayout(true);
Support View
- Recyclerview.
- Listview
- Srcollview
- Gridview
- etc.
Demo
Effect
Subsequent
If necessary, you can add more features to the pull-up load.
Source:
Github Https://github.com/nuptboyzhb/SuperSwipeRefreshLayout
SOURCE Analysis
Follow up with time updates
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Superswiperefreshlayout a powerful custom pull-down refresh component