Created
September 10, 2012 11:21
-
-
Save ljanzik/3690401 to your computer and use it in GitHub Desktop.
Using Pull-To-Refresh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set a listener to be invoked when the list should be refreshed. | |
PullToRefreshListView pullToRefreshView = (PullToRefreshListView) findViewById(R.id.pull_to_refresh_listview); | |
pullToRefreshView.setOnRefreshListener(new OnRefreshListener<ListView>() { | |
@Override | |
public void onRefresh(PullToRefreshBase<ListView> refreshView) { | |
// Do work to refresh the list here. | |
new GetDataTask().execute(); | |
} | |
}); | |
private class GetDataTask extends AsyncTask<Void, Void, String[]> { | |
... | |
@Override | |
protected void onPostExecute(String[] result) { | |
// Call onRefreshComplete when the list has been refreshed. | |
pullToRefreshView.onRefreshComplete(); | |
super.onPostExecute(result); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set a listener to be invoked when the list should be refreshed. | |
PullToRefreshListView pullToRefreshView = (PullToRefreshListView) findViewById(R.id.pull_to_refresh_listview); | |
pullToRefreshView.setOnRefreshListener(new OnRefreshListener<ListView>() { | |
@Override | |
public void onRefresh(PullToRefreshBase<ListView> refreshView) { | |
// Do work to refresh the list here. | |
new GetDataTask().execute(); | |
} | |
}); | |
private class GetDataTask extends AsyncTask<Void, Void, String[]> { | |
... | |
@Override | |
protected void onPostExecute(String[] result) { | |
// Call onRefreshComplete when the list has been refreshed. | |
pullToRefreshView.onRefreshComplete(); | |
super.onPostExecute(result); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
The PullToRefresh-ListView replaces a standard ListView widget, | |
and has all the features android.widget.ListView has. | |
--> | |
<eu.erikw.PullToRefreshListView | |
android:id="@+id/pull_to_refresh_listview" | |
android:layout_height="fill_parent" | |
android:layout_width="fill_parent" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
The PullToRefreshListView replaces a standard ListView widget. | |
The ID CAN NOT be @+id/android:list | |
--> | |
<com.handmark.pulltorefresh.library.PullToRefreshListView | |
android:id="@+id/pull_to_refresh_listview" | |
android:layout_height="fill_parent" | |
android:layout_width="fill_parent" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment