출처 : https://github.com/johannilsson/android-pulltorefresh
This project aims to provide a reusable pull to refresh widget for Android.
Repository at https://github.com/johannilsson/android-pulltorefresh.
Usage
Layout
<!--
The PullToRefreshListView replaces a standard ListView widget.
-->
<com.markupartist.android.widget.PullToRefreshListView
android:id="@+id/android:list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
/>
Activity
// Set a listener to be invoked when the list should be refreshed.
((PullToRefreshListView) getListView()).setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
// Do work to refresh the list here.
new GetDataTask().execute();
}
});
private class GetDataTask extends AsyncTask<Void, Void, String[]> {
...
@Override
protected void onPostExecute(String[] result) {
mListItems.addFirst("Added after refresh...");
// Call onRefreshComplete when the list has been refreshed.
((PullToRefreshListView) getListView()).onRefreshComplete();
super.onPostExecute(result);
}
}
'Android > Tip&Tech' 카테고리의 다른 글
안드로이드] 현재 액티비티, 다른 액티비티 종료하기 (0) | 2013.12.09 |
---|---|
절대로 죽지않는 좀비 서비스 만들기 (0) | 2013.11.27 |
[펌]서로다른 뷰 viewHolder 구현하기 (0) | 2013.11.20 |
[펌]Create a transparent progress dialog on Android (0) | 2013.10.31 |
[펌][안드로이드] Event 처리 메커니즘 (0) | 2013.09.16 |