android – SwipeRefreshLayout多次执行行为(SDK 23)

android – SwipeRefreshLayout多次执行行为(SDK 23),第1张

概述我有SwipeRefreshLayout像这样: .XML: <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/swipe_refresh_layout" android:layou 我有SwipeRefreshLayout像这样:

.XML:

<androID.support.v4.Widget.SwipeRefreshLayout    xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:ID="@+ID/swipe_refresh_layout"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content" >    <androID.support.v7.Widget.RecyclerVIEw        androID:ID="@+ID/haberRecyclerVIEw"        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent" /></androID.support.v4.Widget.SwipeRefreshLayout>

的.java:

private SwipeRefreshLayout swipeLayout;swipeLayout = (SwipeRefreshLayout) rootVIEw.findVIEwByID(R.ID.swipe_refresh_layout);        swipeLayout.setcolorSchemecolors(getResources().getcolor(R.color.primary_color));        swipeLayout.setonRefreshListener(new OnRefreshListener() {            @OverrIDe            public voID onRefresh() {                refreshContent();            }        });

这样我可以多次刷swipeRefresh,旋转动画变得很奇怪,有时它会保持在屏幕上,而不会旋转:

在第一次拉动时,它看起来有点位于顶部,在第二次拉动时,它像图像一样下降.

如何在SwipeRefresh已经刷新时禁用多重拉?
我想这不会发生在sdk 23下面.我正在使用buildTool 23,targetSdk 23,support-v4:23,appcompat-v7:23.

更新:如果我使用ListVIEw而不是RecyclerVIEw,则不会发生这种情况.

解决方法 这个问题在support-v4 23.0.0中引入,是由新的嵌套滚动功能引起的,而不是检查isRefreshing().

您应该扩展SwipeRefreshLayout并覆盖onStartnestedScroll函数:

@OverrIDepublic boolean onStartnestedScroll(VIEw child,VIEw target,int nestedScrollAxes) {    return !isRefreshing() && super.onStartnestedScroll(child,target,nestedScrollAxes);}
总结

以上是内存溢出为你收集整理的android – SwipeRefreshLayout多次执行行为(SDK 23)全部内容,希望文章能够帮你解决android – SwipeRefreshLayout多次执行行为(SDK 23)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1132371.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存