Android XML is added to the listview problem

A problem do not know what reason, code:

 1 public class OtherActivity extends ListActivity {
 2 
 3     @Override
 4     protected void onCreate(Bundle savedInstanceState) {
 5         super.onCreate(savedInstanceState);
 6         //setContentView(R.layout.activity_other);
 7         
 8         //TextView tv1 = (TextView) findViewById(R.id.editText1);
 9         //Gets a XML string.
10         String PaiMaiXML=load();
11         List<String> data = new ArrayList<String>();
12         data.add("The list of license plate");
13         
14         List<Map<String, Object>> PaiMaiList = new ArrayList<Map<String, Object>>(); 
15         Map<String, Object> PaiMaiMap = new HashMap<String, Object>();
16         
17         ByteArrayInputStream tInputStringStream = null;
18         try
19           {
20           if (PaiMaiXML != null && !PaiMaiXML.trim().equals("")) {
21            tInputStringStream = new ByteArrayInputStream(PaiMaiXML.getBytes());
22           }
23           }
24           catch (Exception e) {
25            // TODO: handle exception
26            //tv1.setText(e.getMessage());
27            return;
28           }
29         XmlPullParser parser = Xml.newPullParser();
30           try {
31            parser.setInput(tInputStringStream, "UTF-8");
32            int eventType = parser.getEventType();
33            
34            //List<PaiMaiInfo> PaiMaiList=new ArrayList<PaiMaiInfo>;
35            
36            while (eventType != XmlPullParser.END_DOCUMENT) {
37             switch (eventType) {
38             case XmlPullParser.START_DOCUMENT:// The start of the document, data can be handled
39             // persons = new ArrayList<Person>();
40              break;
41             case XmlPullParser.START_TAG:// Start element event
42              String name = parser.getName();
43              
44              if (name.equalsIgnoreCase("Base_tabletNumber")) {
45               // currentPerson = new Person();
46               // currentPerson.setId(new
47               // Integer(parser.getAttributeValue(null, "id")));
48                  
49               //tv1.setText(parser.nextText());
50                  PaiMaiMap.put("title", parser.nextText()); 
51                  data.add(parser.nextText());
52 
53              } 
54              if(name.equalsIgnoreCase("Base_Family"))
55              {
56                  PaiMaiMap.put("info", parser.nextText());
57                  PaiMaiMap.put("img", R.drawable.ic_launcher); 
58                  PaiMaiList.add(PaiMaiMap);
59                  PaiMaiMap = new HashMap<String, Object>(); 
60              }
61 //              else if (currentPerson != null) {
62 //              if (name.equalsIgnoreCase("loginlink")) {
63 //               currentPerson.setName(parser.nextText());// If the back of Text node, which is the return of its value
64 //              } else if (name.equalsIgnoreCase("errmsg")) {
65 //               currentPerson.setAge(new Short(parser.nextText()));
66 //              }
67 //             }
68              break;
69             case XmlPullParser.END_TAG:// End element event
70 //             if (parser.getName().equalsIgnoreCase("person")
71 //               && currentPerson != null) {
72 //              persons.add(currentPerson);
73 //              currentPerson = null;
74 //             }
75              break;
76             }
77             eventType = parser.next();
78             
79            }
80            tInputStringStream.close();
81            // return persons;
82           } catch (XmlPullParserException e) {
83            // TODO Auto-generated catch block
84            e.printStackTrace();
85           } catch (IOException e) {
86            // TODO Auto-generated catch block
87            e.printStackTrace();
88           }
89           //ListView listView = (ListView) findViewById(R.id.listView1); 
90           //listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,data)); 
91           //setContentView(listView); 
92           SimpleAdapter adapter = new SimpleAdapter(this,PaiMaiList,R.layout.listcell, 
93                     new String[]{"title","info","img"}, 
94                     new int[]{R.id.title,R.id.info,R.id.img}); 
95           setListAdapter(adapter); 
96 
97     }

When I put 51 lines of annotations off on it, seek the truth

Change String wee=parser.nextText (); also has the problem, don't nextText (reason). . .

nextText()Do not repeat, then study the specific reasons

Posted by Beacher at November 18, 2013 - 2:53 PM