类似与谷歌的SwipeRefreshLayout。但比SwipeRefreshLayout美丽。
用法和SwipeRefreshLayout几乎相同。
在xml中:
1
2
3
4
5
6
<com.baoyz.widget.PullRefreshLayout
android:id=``"@+id/swipeRefreshLayout"
android:layout_width=``"match_parent"
android:layout_height=``"match_parent"``>
<!-- ListView、ScrollView、RecyclerView、Other -->
</com.baoyz.widget.PullRefreshLayout>
实例化:
1
2
3
4
5
6
7
8
9
10
PullRefreshLayout layout = (PullRefreshLayout) findViewById(...);
// listen refresh event
layout.setOnRefreshListener(``new
PullRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
// start refresh
}
});
// refresh complete
layout.setRefreshing(``false``);
改变刷新样式:
1
layout.setRefreshStyle(PullRefreshLayout.STYLE_CIRCLES);
有三种样式,各自是:CIRCLES
、 WATER_DROP
和 RING
.
Github下载:https://github.com/baoyongzhang/android-PullRefreshLayout
假设墙不方便:点击下载
手机扫一扫
移动阅读更方便
你可能感兴趣的文章