pulltorefresh使用详解
来源:互联网 发布:仿砍柴网源码破解版 编辑:程序博客网 时间:2024/05/22 16:45
1,属性详解
- <com.handmark.pulltorefresh.library.PullToRefreshListView
- xmlns:ptr="http://schemas.android.com/apk/res-auto"
- android:id="@+id/pull_refresh_list"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:cacheColorHint="#00000000"
- android:divider="#19000000"
- android:dividerHeight="4dp"
- android:fadingEdge="none"
- android:fastScrollEnabled="false"
- android:footerDividersEnabled="false"
- android:headerDividersEnabled="false"
- android:smoothScrollbar="true"
- ptr:ptrMode="both" >
- </com.handmark.pulltorefresh.library.PullToRefreshListView>
product_content_list.setMode(Mode.BOTH);
product_content_list.setOnRefreshListener(new OnRefreshListener2<ListView>() {
@Override
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
//显示时间
String label = DateUtils.formatDateTime(getApplicationContext(), System.currentTimeMillis(),
DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);
refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);
product_condition_text = product_condition.getText().toString();
loadProductList(product_condition_text, 1);
current=1;
}
@Override
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
String label = DateUtils.formatDateTime(getApplicationContext(), System.currentTimeMillis(),
DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);
refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);
current=current+1;
product_condition_text = product_condition.getText().toString();
loadProductList(product_condition_text, current);
}
});
3.handler中的代码
public void handleMessage(android.os.Message msg) {
switch (msg.what) {
case 1:
list=(List<ProductData>) msg.obj;
if(current==1){
adapter = new MyAdapter(list);
refreshableView.setAdapter(adapter);
}else {
adapter.notifyDataSetChanged();
}
product_content_list.onRefreshComplete();
dialogUtils.dissDialog();
break;
case 2:
adapter.notifyDataSetChanged();
dialogUtils.dissDialog();
break;
default:
break;
}
};
4.loadHtttp
TwitterRestClient.get2(Constant.PRODUCT_LIST+id, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
String string=new String(arg2);
Logger.i(TAG,"商品详情"+string);
ProductListBean productListBean = gs.fromJson(string, ProductListBean.class);
if(productListBean==null){
dialogUtils.dissDialog();
product_content_list.onRefreshComplete();
return;
}
if(pageNumber==1){
list.clear();
list = productListBean.data;
}else {
list.addAll((productListBean.data));
}
if(list.size()<0){
showToast("暂无数据");
return;
}
Message message = handler.obtainMessage();
message.obj=list;
message.what=1;
handler.sendMessage(message);
}
- PullToRefresh使用详解
- PullToRefresh使用详解
- PullToRefresh使用详解
- PullToRefresh使用详解
- Android PullToRefresh 使用详解
- PullToRefresh使用详解
- pulltorefresh使用详解
- PullToRefresh使用详解
- PullToRefresh 使用详解
- Android PullToRefresh的使用详解
- PullToRefresh下拉刷新使用详解
- Android PullToRefresh——ListView使用详解
- PullToRefresh 使用
- PullToRefresh使用
- PullToRefresh使用详解(一)--构建下拉刷新的listView
- PullToRefresh使用详解(五)--下拉刷新的ScrollView
- PullToRefresh使用详解(一)--构建下拉刷新的listView
- PullToRefresh使用详解(一)--构建下拉刷新的listView
- Aspects源码解读:动态Block调用(不定参数的Block)
- http://192.168.10.200:50070/windows访问不了 Linux可以
- Asp.Net各种超时问题总结
- C语言知识学习课堂小笔记
- 块级元素和行内元素的区别
- pulltorefresh使用详解
- ios 全面解析block
- Java 强引用、软引用、弱引用、虚引用
- Android控件:WebVIew(三)日历选择器
- Unity内存申请和释放
- 登录测试之用户名或密码要求
- hadoop集群环境多结点搭建
- Android控件:WebVIew(二)显示网页或本地html文件
- Java关键字final、static使用总结