httputils及xlistview刷新
来源:互联网 发布:php微信源码下载 编辑:程序博客网 时间:2024/05/16 04:48
public class MainActivity extends Activity implements IXListViewListener {private XListView xListView;private List<Item> list;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);xListView=(XListView) findViewById(R.id.listView);xListView.setPullRefreshEnable(true); xListView.setPullLoadEnable(true); xListView.setXListViewListener(this); getHttp(1);}protected void getHttp(int cid) {//http://apis.juhe.cn/cook/index?key=3503cb5ddd606f6ab42ead52878007b8&cid=1&dtype=xml// TODO Auto-generated method stubString url="http://apis.juhe.cn/cook/index";HttpUtils httpUtils=new HttpUtils();RequestParams params=new RequestParams(); params.addBodyParameter("key","3503cb5ddd606f6ab42ead52878007b8"); params.addBodyParameter("cid", cid+""); params.addBodyParameter("dtype","xml"); httpUtils.send(HttpMethod.POST, url, params, new RequestCallBack<String>() {@Overridepublic void onFailure(HttpException arg0, String arg1) {// TODO Auto-generated method stubToast.makeText(MainActivity.this, "网络连接失败啦", 0).show();}@Overridepublic void onSuccess(ResponseInfo<String> arg0) {// TODO Auto-generated method stubXStream xStream=new XStream();xStream.processAnnotations(Root.class);Root fromXml=(Root) xStream.fromXML(arg0.result);list=fromXml.getResult().getData().getItem();Log.i("Tag", list.toString());Myadapter adapter=new Myadapter(getApplicationContext(), list);xListView.setAdapter(adapter);}});}@Overridepublic void onRefresh() {// TODO Auto-generated method stubgetHttp(1);onLoad();}private void onLoad() {// TODO Auto-generated method stub xListView.stopRefresh(); xListView.stopLoadMore(); // 设置日期格式 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 获取当前系统时间 String nowTime = df.format(new Date(System.currentTimeMillis())); // 释放时提示正在刷新时的当前时间 xListView.setRefreshTime(nowTime);}@Overridepublic void onLoadMore() {// TODO Auto-generated method stubgetHttp(1);onLoad();}}
0 0
- httputils及xlistview刷新
- HttpUtils请求XML加XListView刷新加载
- HttpUtils请求网络+xlistview上拉刷新,下拉加载
- HttpUtils和XlistView
- XlistView刷新及加载更多
- HttpUtils请求 和XlistView 实现下拉刷新和上拉加载
- pull解析请求网络的数据(带分页加载,刷新) xlistview HttpUtils
- XListView的上拉及下拉刷新
- xlistview刷新
- XListView刷新
- xListView刷新
- XListview刷新
- Xlistview实现上拉刷新下拉加载及item可单选
- XListView上拉刷新数据及加载更多
- XListView下拉刷新
- Xlistview加载刷新小案列
- XListView刷新、加载
- xlistview刷新 加载方法
- 题目1169:比较奇偶数个数
- nexus私服update repair index索引失败解决方案
- viewPager
- 封装javaScript框架思想
- 一直忍让。。脾气激情岂不是受委屈了
- httputils及xlistview刷新
- oracle 里面declare怎么用啊?
- 随意更改网页内容
- 题目:js类型判断
- 对象转型的例子
- Linux : ext3_free_blocks: Freeing blocks not in datazone
- 关于<context:property-placeholder>
- (原) ORA-01704:文字字符串过长
- 鸟哥Java学习之基本数据类型包装类--常用对象API