本文介绍了如何实现拉来刷新一个ListFragment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图推行拉刷新在ListFragment但现在没有在图书馆的下降似乎支持它。有没有办法来检测overscroll名单上的片段​​,我可以看到,所以我想知道是否有人发现得到这个工作的一种手段?

I'm trying implement "pull to refresh" on a ListFragment but right now none of the drop in libraries seem to support it. There's no way to detect overscroll on the list fragment that I can see so I'm wondering if anyone has found a means to get this working?

-

使用基督教的提示,我用下面我onCreateView()方法。

Using Christian's tip I used the following for my onCreateView() method.

@Override
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
   PullToRefreshListView listView = new PullToRefreshListView(getActivity());
   mAdapter = new HomeTweetListAdapter(getActivity(), R.layout.tweet_list_item, tweets);
   listView.setAdapter(mAdapter);
   return listView;
}

就像基督徒说你只能做一个片段。返回以外的任何一ListFragment错误出一个ListView。

Like Christian said you can only do this with a Fragment. Returning anything other than a ListView on a ListFragment errors out.

编辑:为了澄清我使用约翰的PullToRefresh库

To clarify I am using Johan's PullToRefresh library

推荐答案

我实际上使工作中使用的碎片(未 ListFragment )。因此,它基本上是相同的,只返回 PullToRefreshListView onCreateView 的方法,就是这样。它还应该 ListFragment 工作;记住,你必须返回一个的ListView onCreateView 如果你使用 ListFragment (你可以返回任何你想要的,如果你只使用片段)。

I actually make it work using fragments (not ListFragment). So it is basically the same, just return the PullToRefreshListView from your onCreateView method and that's it. It should also work with ListFragment; remember that you must return a ListView from onCreateView if you use ListFragment (you can return whatever you want if you use just Fragment).

这篇关于如何实现拉来刷新一个ListFragment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 06:19