我之前使用的是 API 19,并且在我的许多 fragment 中都使用了 SwipeRefreshLayout
。当我之前第一次加载内容时,我使用的是 setRefreshing(true);
并且能够加载内容并且工作正常。
我注意到在 Android 5.0 中,Google 正在使用循环进度 View 。当我调用 setRefreshing(true);
现在它根本没有效果。无论如何以编程方式显示新的微调器?我已经深入研究了这一点,但无法以编程方式显示它。我已经阅读了以下内容:
http://developer.android.com/tools/support-library/index.html
https://yassirh.com/2014/05/how-to-use-swiperefreshlayout-the-right-way/
SwipeRefreshLayout doesn't show any indicator of refreshing
基本上,它在第一次尝试时没有显示刷新的迹象。
最佳答案
而不是直接设置
getSwipeRefreshLayout().setRefreshing(true);
您可以稍后在 UI 线程上延迟它
getSwipeRefreshLayout().post(new Runnable() {
@Override public void run() {
getSwipeRefreshLayout().setRefreshing(true);
}
});
这对我来说非常适合开始在 onCreateView
中加载,如果在 LoaderManager.LoaderCallbacks
中完成。
我没有看到进度条不小心卡住了(因为数据加载太快了),但是如果您怀疑加载可能会过早返回(错误?)值得做同样的发布强>为
getSwipeRefreshLayout().setRefreshing(false);
这样两个 post
肯定会一个接一个地出现,从而形成一个绝对隐藏的进度 View 。
关于android - API 21 中的 SwipeRefreshLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26601175/