允许上下两方向刷新的SwipeRefreshLayout扩展:SwipyRefreshLayout
jopen
10年前
允许上下两方向刷新的SwipeRefreshLayout扩展。
To include in your project, add this to your build.gradle file:
//SwipyRefreshLayout compile 'com.github.orangegangsters:swipy:1.1.0@aar'
Usage
If you want an example on how to use it, you can find an example app in this repo.
<com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout android:id="@+id/swipyrefreshlayout" android:layout_width="wrap_content" android:layout_height="wrap_content" app:direction="both"> <ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="match_parent" /> </com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout>
mSwipyRefreshLayout.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() { @Override public void onRefresh(SwipyRefreshLayoutDirection direction) { Log.d("MainActivity", "Refresh triggered at " + (direction == SwipyRefreshLayoutDirection.TOP ? "top" : "bottom")); } });
Customization
- XML:
app:direction="top"
OR
app:direction="bottom"
OR
app:direction="both"
- Programmatically:
mSwipyRefreshLayout.setDirection(SwipyRefreshLayoutDirection.TOP);
OR
mSwipyRefreshLayout.setDirection(SwipyRefreshLayoutDirection.BOTTOM);
OR
mSwipyRefreshLayout.setDirection(SwipyRefreshLayoutDirection.BOTH);