一个问题不知什么原因,代码:

 public class OtherActivity extends ListActivity {

     @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_other); //TextView tv1 = (TextView) findViewById(R.id.editText1);
//获取存入的xml字符串
String PaiMaiXML=load();
List<String> data = new ArrayList<String>();
data.add("车牌列表"); List<Map<String, Object>> PaiMaiList = new ArrayList<Map<String, Object>>();
Map<String, Object> PaiMaiMap = new HashMap<String, Object>(); ByteArrayInputStream tInputStringStream = null;
try
{
if (PaiMaiXML != null && !PaiMaiXML.trim().equals("")) {
tInputStringStream = new ByteArrayInputStream(PaiMaiXML.getBytes());
}
}
catch (Exception e) {
// TODO: handle exception
//tv1.setText(e.getMessage());
return;
}
XmlPullParser parser = Xml.newPullParser();
try {
parser.setInput(tInputStringStream, "UTF-8");
int eventType = parser.getEventType(); //List<PaiMaiInfo> PaiMaiList=new ArrayList<PaiMaiInfo>; while (eventType != XmlPullParser.END_DOCUMENT) {
switch (eventType) {
case XmlPullParser.START_DOCUMENT:// 文档开始事件,可以进行数据初始化处理
// persons = new ArrayList<Person>();
break;
case XmlPullParser.START_TAG:// 开始元素事件
String name = parser.getName(); if (name.equalsIgnoreCase("Base_tabletNumber")) {
// currentPerson = new Person();
// currentPerson.setId(new
// Integer(parser.getAttributeValue(null, "id"))); //tv1.setText(parser.nextText());
PaiMaiMap.put("title", parser.nextText());
data.add(parser.nextText()); }
if(name.equalsIgnoreCase("Base_Family"))
{
PaiMaiMap.put("info", parser.nextText());
PaiMaiMap.put("img", R.drawable.ic_launcher);
PaiMaiList.add(PaiMaiMap);
PaiMaiMap = new HashMap<String, Object>();
}
// else if (currentPerson != null) {
// if (name.equalsIgnoreCase("loginlink")) {
// currentPerson.setName(parser.nextText());// 如果后面是Text节点,即返回它的值
// } else if (name.equalsIgnoreCase("errmsg")) {
// currentPerson.setAge(new Short(parser.nextText()));
// }
// }
break;
case XmlPullParser.END_TAG:// 结束元素事件
// if (parser.getName().equalsIgnoreCase("person")
// && currentPerson != null) {
// persons.add(currentPerson);
// currentPerson = null;
// }
break;
}
eventType = parser.next(); }
tInputStringStream.close();
// return persons;
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//ListView listView = (ListView) findViewById(R.id.listView1);
//listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,data));
//setContentView(listView);
SimpleAdapter adapter = new SimpleAdapter(this,PaiMaiList,R.layout.listcell,
new String[]{"title","info","img"},
new int[]{R.id.title,R.id.info,R.id.img});
setListAdapter(adapter); }

当我把51行的注释掉就可以了,求真相

改成String wee=parser.nextText(); 也是有问题,难道nextText()的原因。。。

nextText()不能重复执行,具体原因 再研究

android xml解析添加到listview中的问题的更多相关文章

  1. android XMl 解析神奇xstream 五: 把复杂对象转换成 xml ,并写入SD卡中的xml文件

    前言:对xstream不理解的请看: android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 android XMl 解析神奇xs ...

  2. Android] Android XML解析学习——方式比较

     [Android] Android XML解析学习——方式比较 (ZT)  分类: 嵌入式 (From:http://blog.csdn.net/ichliebephone/article/deta ...

  3. android XMl 解析神奇xstream 六: 把集合list 转化为 XML文档

    前言:对xstream不理解的请看: android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 android XMl 解析神奇xs ...

  4. android XMl 解析神奇xstream 四: 将复杂的xml文件解析为对象

    前言:对xstream不理解的请看: android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 android XMl 解析神奇xs ...

  5. android XMl 解析神奇xstream 三: 把复杂对象转换成 xml

    前言:对xstream不理解的请看: android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 android XMl 解析神奇xs ...

  6. android XMl 解析神奇xstream 二: 把对象转换成xml

    前言:对xstream不理解的请看:android XMl 解析神奇xstream 一: 解析android项目中 asset 文件夹 下的 aa.xml 文件 1.Javabeen 代码 packa ...

  7. C# 将Access中时间段条件查询的数据添加到ListView中

    C# 将Access中时间段条件查询的数据添加到ListView中 一.让ListView控件显示表头的方法 在窗体中添加ListView 空间,其属性中设置:View属性设置为:Detail,Col ...

  8. Android XML解析

    解析XML有三种方式:Dom.SAX.Pull 其中pull解析器运行方式与SAX类似. 我们首先认识pull解析器:http://developer.android.com/intl/zh-cn/r ...

  9. Android XML解析器的问题

    最近在项目中遇到了一个解析XML的问题,我们是用android自带的DOM解析器来解析XML的,但发现了一个android的问题,那就是在2.3的SDK上面,无法解析像<, >, 等字符串 ...

随机推荐

  1. AWK文本处理工具(Linux)

    AWK文本处理工具(Linux) PS:刚开始实习,就给了个处理百万级别数据的任务,以前学过SHELL的一些东西sed/awk之类的处理,但是也没有具体的应用,只是在10几行10几列的小数据操作过,所 ...

  2. jenkins插件 查看job修改历史

    文章来自:http://www.ciandcd.com文中的代码来自可以从github下载: https://github.com/ciandcd 插件jobConfigHistory(https:/ ...

  3. 我们可以用SharePoint做什么

    前言 不知不觉作为一个SharePoint的开发人员若干年了,从SharePoint api 开始学习,到了解SharePoint的结构,逐渐一点点了解sharepoint的体系:从SharePoin ...

  4. js 函数提升和变量提升

    总结: 函数提升比变量提升优先级高! 词法分析 词法分析方法: js运行前有一个类似编译的过程即词法分析,词法分析主要有三个步骤: 分析参数 再分析变量的声明 分析函数说明 具体步骤如下: 函数在运行 ...

  5. [转]HTTP协议及其请求头分析

      众所周知,Internet的基本协议是TCP/IP协议,目前广泛采用的FTP.Archie Gopher等是建立在TCP/IP协议之上的应用层协议,不同的协议对应着不同的应用.  WWW服务器使用 ...

  6. android WebView控件显示网页

    有时需要app里面显示网页,而不调用其他浏览器浏览网页,那么这时就需要WebView控件.这个控件也是很强大的,放大,缩小,前进,后退网页都可以. 1.部分方法 //支持javascriptweb.g ...

  7. Liferay7 BPM门户开发之30: 通用帮助类Validator、ArrayUtil、StringUtil等使用

    废话不多说,直接上代码. 验证类Validator 主要是空验证.数字.格式验证 调用的例子: protected void validateEmailFrom(ActionRequest actio ...

  8. AngularJS(一)

    什么是AngularJS[双向数据绑定:从界面的操作能实时反映到数据,数据的变更能实时展现到界面.]?1.AngularJS 使得开发现代的单一页面应用程序(SPAs:Single Page Appl ...

  9. aehyok.com的成长之路三——框架结构

    前言 首先奉上个人网站地址传送门:aehyok.com. aehyok.com的成长之路一——开篇 中主要阐述了自己为什么建立自己的网站,以及个人网站的大致方向. aehyok.com的成长之路二—— ...

  10. Entity Framework6 with Oracle

    Entity Framework6 with Oracle(可实现code first) Oracle 与2个月前刚提供对EF6的支持.以前只支持到EF5.EF6有很多有用的功能 值得升级.这里介绍下 ...