本文介绍了关于如何使用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实现了更新方法,当新的数据已准备好被调用。

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();
}

所以我假定这是所有我需要启动拉来刷新的开始。如果是这样,更新里面我该怎么做才能结束通话?

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(假)

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

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

09-12 22:28