关于如何将 SwipeRefreshLayout 与 ListView 一起使用的简单示例

编程入门 行业动态 更新时间:2024-10-10 10:26:39
本文介绍了关于如何将 SwipeRefreshLayout 与 ListView 一起使用的简单示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有人有一个关于如何将 SwipeRefreshLayout 与 ListView 一起使用的简单示例?这是我的情况:

Does anyone have a simple example on how to use SwipeRefreshLayout with a ListView? Here is my situation:

我有一个类 SynchDogs,它从服务器中提取数据.因此该类用作我的适配器的源.我想使用 SwipeRefreshLayout 来刷新适配器和 ListView.DogActivity 是 SynchDogs 的观察者,因此 DogActivity 实现了一个 update 方法,该方法在新数据准备好时调用.

I have a class SynchDogs that pulls data from the server. So that class serves as the source for my adapter. I want to use SwipeRefreshLayout for refreshing the adapter and so the ListView. DogActivity is an Observer of SynchDogs so that DogActivity implements an update method that is called when new data is ready.

所以我将 onRefresh 实现为

@Override public void onRefresh() { SynchDogs.getInstance().synchronizeWithServer(); }

所以我假设这就是启动下拉刷新所需的全部内容.如果是这样,在 update 中我该怎么做才能结束通话?

So I am supposing this is all I need to initiate the start of pull-to-refresh. If so, inside update what do I do to end the call?

我也有

swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container); swipeLayout.setOnRefreshListener(this); swipeLayout.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light);

更新

基本上,我想知道停止彩色表演的呼吁.

Basically, I want to know the call for stopping the color show.

推荐答案

调用方法setRefreshing(false)

developer.android/reference/android/support/v4/widget/SwipeRefreshLayout.html#setRefreshing(boolean)

更多推荐

关于如何将 SwipeRefreshLayout 与 ListView 一起使用的简单示例

本文发布于:2023-11-25 16:56:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630582.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:示例   如何将   简单   ListView   SwipeRefreshLayout

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!