private void getData(final String s) {
i++;
// 请求网络数据
HttpUtils utils = new HttpUtils();
utils.send(HttpMethod.GET, url + i, new RequestCallBack<String>() {
@Override
public void onFailure(HttpException arg0, String arg1) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(ResponseInfo<String> arg0) {
String result = arg0.result;// 得到结果
// 请求数据成功后解析xml文件
XStream stream = new XStream();
// 解析封装到实体类
stream.processAnnotations(SuperClass.class);
SuperClass class1 = (SuperClass) stream.fromXML(result);
// 保存到集合
list = class1.getTweets().getTweet();
System.out.println("解析的集合:" + list);
// 发送handler消息
if (s.equals("刷新")) {
handler.sendMessage(handler.obtainMessage(1, list));
}
if (s.equals("加载")) {
handler.sendMessage(handler.obtainMessage(2, list));
} else {
handler.sendMessage(handler.obtainMessage(3, list));
}
}
});
}