有没有一种方法可以使用SwipeRefreshLayout
在从底部拉动ListView
时进行刷新?
我已经创建了从顶部拉动的功能,但我还需要从底部拉动。有许多关于如何创建从顶部拉动的教程,但我找不到任何关于从底部拉动的教程。
有没有一种方法可以使用SwipeRefreshLayout
在从底部拉动ListView
时进行刷新?
我已经创建了从顶部拉动的功能,但我还需要从底部拉动。有许多关于如何创建从顶部拉动的教程,但我找不到任何关于从底部拉动的教程。
来自Android Support Library版本21的SwipeRefreshLayout不支持从底部拉取。 我对基于原始SwipeRefreshLayout代码的SwipeRefreshLayoutBottom进行了修改。 它完全基于原始的Google代码,只是坐标的翻转和canChildScrollDown方法的重写实现。所有修改都标记为TODO。
使用这个优秀的库:OrangeGangsters SwipyRefreshLayout
这样你就可以从顶部和底部进行滑动,并支持 API 9+。
如果您的情况需要,omadahealth/SwipyRefreshLayout库一定是您的答案。
以下代码可以让您的Recycler view从底部向上拉以进行刷新
:
<com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/refresh_layout"
style="@style/View_MatchParent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:srl_direction="bottom"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
style="@style/View_MatchParent"
android:layout_height="wrap_content"
android:clipToPadding="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout>
我遇到了同样的问题,我通过结合swipeRefreshLayout和列表中的触摸事件来解决它。这是链接:
不,你不能使用SwipeRefreshLayout来实现这个。你需要自己实现布局,这并不难。
请查看这个链接: http://erikw.eu/open-source-android-pull-to-refresh-library/ 和这个链接: http://www.oodlestechnologies.com/blogs/Implementing-Pull-to-refresh-(like-in-Facebook-mobile-app)-for-ANDROID-using-Titanium