Android Learning two dropdown refresh library share

Source: Internet
Author: User

I didn't write a blog yesterday. The heart is very guilty, today to everyone write two more common use of drop-down refresh. One is Swiperefreshlayout, one is circlerefreshlayout.

The use of Swiperefreshlayout

Post the layout:

<android. Support. V4. Widgets. SwiperefreshlayoutAndroid:id="@+id/layswiperefresh"Android:layout_width="Match_parent"android:layout_height="Match_parent"> <com. Example. Boao. Widgets. AutorecyclerviewAndroid:id="@+id/recyclerview"Android:layout_width="Match_parent"android:layout_height="Match_parent"/> </android. Support. V4. Widgets. Swiperefreshlayout>

Can see Swiperefreshlayout is based on the V4 package, that is the surface of this is the official Google recommended to use, just to join the V4 package can be

Simple layout settings are available with swiperefreshlayout including Recyclerview,listview,gridview.

Now let's see how it's used in the code.

swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {            @Override            publicvoidonRefresh() {                getDatas();            }        });

Instantiation Swiperefreshlayout I'm not going to talk, call Swiperefreshlayout's Setonrefreshlistener method, listen for loading events, and invoke the method of requesting data in the Onrefresh () method to refresh the data

Of course this is not finished, because the end of the refresh has not been set

Call Swiperefreshlayout.setrefreshing (FALSE) after the request data is successful, and the setting is not refreshed.

Swiperefreshlayout Refresh effect Show

The method of swiperefreshlayout includes much more than this. The method of Swiperefreshlayout included on the sticker

From the top down:
1. Set the size of the refresh circle
2. Set whether to refresh
3. Set the background color of the refresh
4. Ibid.
5. Set the drop-down distance to trigger the refresh
6. Set the background color of the refresh

All right. Swiperefreshlayout introduced to this.

Next Introduction Circlerefreshlayout

This is a third-party library https://github.com/tuesda/CircleRefreshLayout, with similar swiperefreshlayout,

Put it on, see if you want to use it.

Usage

<com. TUESDA. Walker. Circlerefresh. Circlerefreshlayoutxmlns:app="Http://schemas.android.com/apk/res-auto"App:anibackcolor="#ff8b90af"App:aniforecolor="#ffffffff"App:circlesmaller="6"Android:id="@+id/refresh_layout"Android:layout_width="Match_parent"android:layout_height="Match_parent"> <listview android:background="#ffffffff"Android:id="@+id/list"Android:layout_width="Match_parent"android:layout_height="Match_parent"></ListView> </com. TUESDA. Walker. Circlerefresh. Circlerefreshlayout>

The first paragraph is the same, including the list layout

mRefreshLayout.setOnRefreshListener(                new CircleRefreshLayout.OnCircleRefreshListener() {            @Override            publicvoidrefreshing() {                // do something when refresh starts            }            @Override            publicvoidcompleteRefresh() {                // do something when refresh complete            }        });

The request data method is called in the refreshing () method. Completerefresh () No action is necessary. After the request interface succeeds

Call Mrefreshlayout.finishrefreshing (); To stop the flush, just like swiperefreshlayout.

Unfortunately, this library does not have the option of adding dependencies, it cannot be used directly, so it needs to be integrated into the project.

Let's look at my integrated structure diagram below

Download the source code down, integration is very easy, everyone try it, today's study is here

Android Learning two dropdown refresh library share

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.