Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with android-pulltorefresh widget

I am having a bit of difficulty implementing the android-pulltorefresh widget by Johan Nilsson found at https://github.com/johannilsson/android-pulltorefresh

The problem I am having is after putting the custom listview into my application everything is fine it, but it asks to Tap to Refresh the list view but I need it to be set to pull down to refresh.

The code I am using below is pretty much from the github page and a screenshot of the app can be found below do demonstrate my issue:

PullToRefreshListView lv = (PullToRefreshListView)findViewById(R.id.listView);
lv.setOnRefreshListener(new OnRefreshListener() {
    public void onRefresh() {
    // Do work to refresh the list here.
    GetData getData = new GetData();
    getData.execute();
}

enter image description here

I need the Tap to refresh header gone and only to be shown once the listview has been dragged down. I get the feeling I just need to change some sort of flag but I can't find where this would be.

like image 545
SamRowley Avatar asked Nov 13 '22 05:11

SamRowley


1 Answers

Unfortunately there is no way to work around this. The entire control is built around the idea that the "Pull to Refresh" header is a normal listview item that gets hidden by scrolling the list upward. Unfortunately, when you have a very short list, the list cannot be scrolled upward to hide the first item cause there are not enough items in the list -- so the fallback is to show the first item (the header) as well and have it display "Tap to Refresh".

EDIT: One kludge you may be able to do is insert dummy blank items so the list has enough items to hide the top header list item.

like image 116
Theo Avatar answered Nov 16 '22 02:11

Theo