允許上下兩方向刷新的SwipeRefreshLayout擴展:SwipyRefreshLayout

jopen 9年前發布 | 78K 次閱讀 Android開發 移動開發 SwipyRefreshLayout

允許上下兩方向刷新的SwipeRefreshLayout擴展。

To include in your project, add this to your build.gradle file:

//SwipyRefreshLayout
   compile 'com.github.orangegangsters:swipy:1.1.0@aar'

Demo

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);


項目主頁:http://www.baiduhome.net/lib/view/home/1426140864170

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!