- get widget pulltorefreshlistview and call setOnRefreshListener(),overide method onRefresh or onPullDwonToRefresh,onPullUpToRefresh:
mPullRefreshListView.setOnRefreshListener(new OnRefreshListener2<ListView>() {
@Override
public void onPullDownToRefresh(
PullToRefreshBase<ListView> refreshView) {
// TODO Auto-generated method stub
String label = DateUtils.formatDateTime(getApplicationContext(), System.currentTimeMillis(),
DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);
sp.edit().putString("lastUpdateTime",label).commit();
refreshView.getLoadingLayoutProxy(true,false).setLastUpdatedLabel(label);
flag = false;
new GetDataTask().execute();
}
@Override
public void onPullUpToRefresh(
PullToRefreshBase<ListView> refreshView) {
// TODO Auto-generated method stub
//refreshView.getLoadingLayoutProxy().setLastUpdatedLabel("上拉更多");
refreshView.getLoadingLayoutProxy(false, true).setPullLabel("加载更多");
refreshView.getLoadingLayoutProxy(false, true).setReleaseLabel("加载更多");
refreshView.getLoadingLayoutProxy(false, true).setRefreshingLabel("正在加载");
//refreshView.getLoadingLayoutProxy(false, true)
flag = true;
new GetDataTask().execute();
}
- refreshView.getLoadingLayoutProxy(true,false).setLastUpdatedLabel(label);
the params means using style for the top or bottom refresh view or not
- show the lastUpdateTime at first sight,you can store the time in sharedprefrences and get the value in method oncreate()