我想从下面的 xml 文件中创建一个列表视图:
<Menu>
<Project name ="Desktop Application">
<name>Desktop Application</name>
<Description>This is some text.</Description>
<image>2130837532</image>
<Sub>
<SubName>PowerISO</SubName>
<SubDescription>This is some text.</SubDescription>
<SubImage>2130837555</SubImage>
</Sub>
<Sub>
<SubName>Microsoft Office</SubName>
<SubDescription>This is some text.</SubDescription>
<SubImage>2130837549</SubImage>
</Sub>
<Sub>
<SubName>Adobe Reader</SubName>
<SubDescription>This is some text.</SubDescription>
<SubImage> 2130837506 </SubImage>
</Sub>
<Sub>
<SubName>Vlc Player</SubName>
<SubDescription>This is some text.</SubDescription>
<SubImage>2130837587</SubImage>
</Sub>
<Sub>
<SubName>Picasa Photo Viewer</SubName>
<SubDescription>This is some text.</SubDescription>
<SubImage>2130837554</SubImage>
</Sub>
<Sub>
<SubName>KM Player</SubName>
<SubDescription>This is some text.</SubDescription>
<SubImage>2130837542</SubImage>
</Sub>
<Sub>
<SubName>Cricket</SubName>
<SubDescription>This is some text.</SubDescription>
<SubImage>2130837524</SubImage>
</Sub>
</Project>
依此类推,但是我已经为主要项目创建了一个,但是在单击其中一个之后,我想根据主要项目显示子项目。我无法创建第二个列表,该列表将根据主要项目显示子项目。我已经使用 SAX 解析器完成了这项工作。请帮我做这件事。
这是我的 startElement() 方法,我希望如果项目名称是桌面应用程序,那么桌面应用程序的子项目将显示在列表视图上。我没有得到这个。请帮我!!
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
// TODO Auto-generated method stub
currentElement = true;
if (qName.equals("Menu")) {
subList = new ArrayList<SubProjectInfo>();
} else if (qName.equals("Project")) {
subProInfo1 = new SubProjectInfo();
String gh = attributes.getValue("name");