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?
--
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;
}
Like Christian said you can only do this with a Fragment. Returning anything other than a ListView on a ListFragment errors out.
EDIT: To clarify I am using Johan's PullToRefresh library
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
).