Android swiperefreshlayout drop-down refresh component example

Swiperefreshlayout overview

Swiperegreshlayout is a widget officially updated by Google, which can achieve the effect of drop-down refresh. The control is integrated from ViewGroup under the support-v4 compatibility package, but we need to upgrade the version of supportlibrary to above 19.1.

Users refresh the content view by gesture or clicking a button. Swiperefreshlayout is added to the layout to nest a sub view, such as listview and recyclerview. Triggering the refresh will be recalled through onrefresh method of onrefreshlistener. Here we refresh the page data, and a notification will be executed every time the gesture is completed, Determine whether callback is required according to the sliding distance. Setrefreshing (false) directly cancels the refresh through the code. If true, manually set refresh to call out the refresh view. Setenabled (false) controls whether to disable gesture refresh through Boolean.

The basic methods used are as follows:

1. Setonrefreshlistener (onrefreshlistener): add a drop-down refresh listener

2. Setrefreshing (Boolean): displays or hides the refresh progress bar

3. Isrefreshing(): check whether it is in refresh status

It is very simple to use. A simple case is used to introduce the function of swiperefreshlayout drop-down refresh.

Layout file

item.xml

Activity

The operation effect is shown in the figure below:

Click to download the source code: swiperefreshlayout_ jb51.rar

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>