关于如何将 SwipeRefreshLayout 与 ListView 一起使用的简单示例 [英] simple example on how to use SwipeRefreshLayout with ListView

查看:10
本文介绍了关于如何将 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)

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

这篇关于关于如何将 SwipeRefreshLayout 与 ListView 一起使用的简单示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆