XStream解析
package com.baidu.farment;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.client.ClientProtocolException;
import com.baidu.net.Network;
import com.baidu.vo.Mynews;
import com.baidu.vo.Mynewslist;
import com.baidu.vo.Super;
import com.example.xlistviews.XListView;
import com.example.xlistviews.XListView.IXListViewListener;
import com.example.yuekao1.Base;
import com.example.yuekao1.R;
import com.thoughtworks.xstream.XStream;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;
public class F1 extends Fragment implements IXListViewListener {
private XListView lv;
private String URL;
public F1(String URL) {
this.URL = URL;
}
ArrayList<Mynews> li = new ArrayList<Mynews>();
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = View.inflate(getActivity(), R.layout.f1, null);
lv = (XListView) view.findViewById(R.id.lv);
lv.setPullLoadEnable(true);
lv.setPullRefreshEnable(true);
lv.setXListViewListener(this);
new Asy().execute();
return view;
}
class Asy extends AsyncTask<String, Integer, String> {
private String ss1;
private ArrayList<Mynews> news;
@Override
protected String doInBackground(String... params) {
try {
ss1 = Network.getjson(URL);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ss1;
}
@Override
protected void onPostExecute(String result) {
// t1.setText(result);
XStream xs = new XStream();
xs.processAnnotations(Super.class);
Super ss = (Super) xs.fromXML(result);
news = ss.getNewslist().getNews();
li = news;
Base b = new Base(news, getActivity());
lv.setAdapter(b);
}
}
class Asynt extends AsyncTask<String, Integer, String> {
private String ss1;
private ArrayList<Mynews> news;
@Override
protected String doInBackground(String... params) {
try {
ss1 = Network.getjson(URL);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ss1;
}
@Override
protected void onPostExecute(String result) {
// t1.setText(result);
XStream xs = new XStream();
xs.processAnnotations(Super.class);
Super ss = (Super) xs.fromXML(result);
news = ss.getNewslist().getNews();
li.addAll(news);
Base b = new Base(news, getActivity());
b.notifyDataSetInvalidated();
}
}
public void onRefresh() {
new Asy().execute();
onLoad();
}
public void onLoadMore() {
new Asynt().execute();
onLoad();
}
private void onLoad() {
lv.stopRefresh();
lv.stopLoadMore();
lv.setRefreshTime("2016-4-1");
}
}
XStream解析的更多相关文章
- 使用XStream解析MXL文件用到的jar包---xpp3_min-1.1.3.4.O.jar和xstream-1.3.1.jar
使用XStream解析MXL文件用到的jar包---xpp3_min-1.1.3.4.O.jar和xstream-1.3.1.jar
- 20190408 XStream解析List
XStream解析List 使用的JavaBean 普通JavaBean public class Book { private String name; public Book() { } publ ...
- Xstream解析XML
<oschina> <catalog>1</catalog> <newsCount>0</newsCount> <pagesize&g ...
- (转载)XML解析之-XStream解析
转载来源:http://hwy584624785.iteye.com/blog/1168680 本例使用XStream生成一个xml文件,再发序列化xml文件内容. XStream是一个简单的类库,可 ...
- 使用XStream解析复杂XML并插入数据库(二)
标注黄色地方:我需要加深学习!!! 我写的是webservice,目前具体写webservice的步骤我还不清楚, 整理完小知识开始整理webservice! 针对以下格式的XML进行解析 <? ...
- 使用XStream解析复杂XML并插入数据库(一)
环境: Springboot+mysql 我只想说jpa真的超级好用,准备深入研究一下~ 导入依赖: <dependency> <groupId>org.projectlomb ...
- Xstream 解析xml文件内容
刚刚接手的一个项目,接到一个对接用户数据的需求,对方使用的是xml格式来传输文件,特此记下解析该类文件的方法 public interface XmlResolver<T> { XStre ...
- 【转】十分详细的xStream解析
转自博文:http://www.cnblogs.com/hoojo/archive/2011/04/22/2025197.html xStream框架 xStream可以轻易的将Java对象和xml文 ...
- xstream 解析xml报文
一.xml一种格式的数据转换为对象 pom.xml引入 <!--javaBean和XML的双向转换--> <dependency> <groupId>com.tho ...
随机推荐
- c#中使用servicestackredis操作redis
下载地址: https://github.com/mythz/ServiceStack.Redis 添加dll引用: using ServiceStack.Common.Extensions;usin ...
- https需要的类
import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import j ...
- Oracle创建用户并给用户授权查询指定表或视图的权限
MSV31账户登录数据库进行如下操作: CREATE USER NORTHBOUND IDENTIFIED BY NORTHBOUND DEFAULT TABLESPACE "TBS_DN ...
- SharePoint 2016 的新特性概览(一)(What's New for IT Professionals in SharePoint Server 2016)
博客地址:http://blog.csdn.net/FoxDave 今天看霖雨大神的转的微软最新的关于SharePoint 2016的Update,正好看到了SP2016新发布的视频,整理一下发出 ...
- 【iOS开发】企业版证书($299)In-House方式发布指南 (转)
一.明确几个概念 1.企业版IDP:即iOS Development Enterprise Program.注意是$299/Year那种,并不是$99/Year的那种. 2.In House:是只企业 ...
- poj3126 筛素数+bfs
//Accepted 212 KB 16 ms //筛素数+bfs #include <cstdio> #include <cstring> #include <iost ...
- Ubuntu 14.10 下Ganglia监控Hadoop集群
前提是已经安装好Ganglia和Hadoop集群 1 Master节点配置hadoop-metrics2.properties # syntax: [prefix].[source|sink|jmx] ...
- Connection to http://www.google.com:80 refused
使用SDK Manager更新时出现问题 Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-6.x ...
- 2016 - 1- 22 NSURLConnetction --- GET请求
---恢复内容开始--- 一: 给服务器发送一个简单的GET请求 1.同步 // 发送一个GET请求给服务器 // 0.请求路径 NSURL *url = [NSURL URLWithString:@ ...
- GSM Hacking:使用BladeRF、树莓派、YatesBTS搭建便携式GSM基站
每次看到黑客在网上发布的那些GSM技术相关文章我都十分惊讶.然而在没有Software Defined Radios (SDRs)之前,玩GSM并不便宜,除此之外想要好好玩你得下大功夫. 拓展阅读 G ...