ChrisBanes PullToRefresh“载入中...”问题 [英] ChrisBanes PullToRefresh 'Loading...' issue
问题描述
我使用PullToRefresh的ListView从中我发现chrisbanes 这里。
I am using PullToRefresh ListView from chrisbanes which I found here.
我实现它成功,这要归功于其文档。 :)
I implemented it successfully, thanks to its documentations. :)
不过,我现在停留在这一个点上。我使用的凌空抽射从服务器获取数据。它完美,直到我添加了一个检查,看看世界上没有更多的数据,然后简单地敬酒用户。
However, I am stuck at this one point now. I am using volley to get the data from the server. It works perfectly till I added a check to see if theres no more data then simply Toast the user.
我不喜欢以下,
@Override
public void onRefresh(
PullToRefreshBase<ListView> refreshView) {
if (hasMoreData()){
//Call service when pulled to refresh
orderService();
} else{
// Call onRefreshComplete when the list has been refreshed.
toastShort("No more data to load");
orderListAdapter.notifyDataSetChanged();
mPullRefreshListView.onRefreshComplete();
}
}
敬酒来了,但我也继续看到在载入中... 消息下面我的ListView。我以为 onRefreshComplete();
应该照顾它,但它没有。
The toast comes up, but I also continue seeing the Loading... message below my ListView. I thought onRefreshComplete();
should take care of it but it didn't.
我如何做到这一点?请大家帮帮忙。
How do I do this? Please help.
推荐答案
敲打我的脑袋几乎3小时我能解决这个问题之后。这是相当简单硬朗。
After banging my head for almost 3hours I was able to solve this. It was quite simple tough.
我所做的就是创建一个处理程序和 mPullRefreshListView.onRefreshComplete()一个Runnable它调用;
并经过一段时间检查,如果 mPullRefreshListView
仍令人耳目一新然后再次调用该方法而关闭它的下一个电话。 :)
What I did was created a Handler and a Runnable which calls mPullRefreshListView.onRefreshComplete();
and checked after some time that if mPullRefreshListView
was still refreshing then call the method again which closes it on the next call. :)
code是这样的。
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
if (hasMoreData()) {
// Call service when pulled to refresh
toastShort("Last");
orderService();
} else {
// Call onRefreshComplete when the list has been
// refreshed.
toastShort("No more data to load");
upDatePull(); //this method does the trick
}
}
private void upDatePull() {
// lvOrders.setAdapter(null);
handler = new Handler();
handler.postDelayed(runnable, 1000);
}
Runnable runnable = new Runnable() {
@Override
public void run() {
mPullRefreshListView.onRefreshComplete();
if (mPullRefreshListView.isRefreshing()) {
Logger.d("xxx", "trying to hide refresh");
handler.postDelayed(this, 1000);
}
}
};
贷此链接。
这篇关于ChrisBanes PullToRefresh“载入中...”问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!