Android XML Pull Parser子节点问题
我的应用程序包括两个活动:
第一个活动将包含从 xml 文件动态创建的一组按钮,当我们单击这些按钮时,第二个活动启动。在第二个活动中,我有可扩展的列表视图,可以根据第一个活动中单击的按钮进行填充。
我的 xml 文件是这样的:
<classes>
<class name="3">
<syllabus name="ICSE " code="ic" id="" >
<subject name="maths">3 ICSE Maths data</subject>
<subject name="physics">3 ICSE Physics data</subject>
<subject name="chemistry">3 ICSE Chemistry data</subject>
</syllabus>
<syllabus name="cbse" code="cb" id="" >
<subject name="maths">3 CBSE Maths data</subject>
<subject name="physics">3 CBSE Physics data</subject>
<subject name="chemistry">3 CBSE Chemistry data</subject>
</syllabus>
</class>
<class name="4">
<syllabus name="ICSE " code="ic" id="" >
<subject name="maths">4 ICSE Maths data</subject>
<subject name="physics">4 ICSE Physics data</subject>
<subject name="chemistry">4 ICSE Chemistry data</subject>
</syllabus>
<syllabus name="cbse" code="cb" id="" >
<subject name="maths">4 CBSE Maths data</subject>
<subject name="physics">4 CBSE Physics data</subject>
<subject name="chemistry">4 CBSE Chemistry data</subject>
</syllabus>
<syllabus name="ssc" code="ss" id="" >
<subject name="maths">4 CBSE Maths data</subject>
<subject name="physics">4 CBSE Physics data</subject>
<subject name="chemistry">4 CBSE Chemistry data</subject>
</syllabus>
</class>
</classes>
在上面的 xml 文件中,类属性名称是我的第一个活动的按钮。就像
类 3
类 4
类 5
类 6
当用户单击特定按钮时,他将被带到另一个具有可扩展列表视图的活动,它看起来像这样:
--> CBSE
Maths
Physics
Science
--> ICSE
Maths
Physics
Science
现在我需要填充这个可扩展列表从 xml 动态列表视图,其中包含 xml 中特定类标记的子节点。 例如,如果用户单击 class3 按钮,则可扩展列表视图必须填充 ICSE 和 CBSE。
如果用户单击 class4 按钮,可扩展列表视图必须从 xml 动态填充 ICSE、CBSE 和 SSC。
请帮助我如何使用示例代码执行此操作。
先感谢您。
My application includes two activities :
1st activity will contain set of buttons created dynamically from the xml file, when we click on these buttons 2nd activity starts. In 2nd activity i have expandable list view to be populated according to the button clicked in 1st activity.
My xml file is like this :
<classes>
<class name="3">
<syllabus name="ICSE " code="ic" id="" >
<subject name="maths">3 ICSE Maths data</subject>
<subject name="physics">3 ICSE Physics data</subject>
<subject name="chemistry">3 ICSE Chemistry data</subject>
</syllabus>
<syllabus name="cbse" code="cb" id="" >
<subject name="maths">3 CBSE Maths data</subject>
<subject name="physics">3 CBSE Physics data</subject>
<subject name="chemistry">3 CBSE Chemistry data</subject>
</syllabus>
</class>
<class name="4">
<syllabus name="ICSE " code="ic" id="" >
<subject name="maths">4 ICSE Maths data</subject>
<subject name="physics">4 ICSE Physics data</subject>
<subject name="chemistry">4 ICSE Chemistry data</subject>
</syllabus>
<syllabus name="cbse" code="cb" id="" >
<subject name="maths">4 CBSE Maths data</subject>
<subject name="physics">4 CBSE Physics data</subject>
<subject name="chemistry">4 CBSE Chemistry data</subject>
</syllabus>
<syllabus name="ssc" code="ss" id="" >
<subject name="maths">4 CBSE Maths data</subject>
<subject name="physics">4 CBSE Physics data</subject>
<subject name="chemistry">4 CBSE Chemistry data</subject>
</syllabus>
</class>
</classes>
In above xml file class attribute name is my button of 1st activity. like
class 3
class 4
class 5
class 6
when the user clicks on particular button he will be taken to another activity with expandable list view, it looks like this:
-->CBSE
Maths
Physics
Science
-->ICSE
Maths
Physics
Science
Now i need to populate this expandable list view dynamically from the xml with the child nodes of particular class tag in xml.
For example if user clicks on class3 button expandable list view has to get populated with ICSE and CBSE.
And if user clicks on class4 button expandable list view has to get populated with ICSE, CBSE and SSC dynamically from xml.
Please help me how to do this with sample code.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论