开发者

Android XML Pull Parser child nodes problem

开发者 https://www.devze.com 2023-03-07 22:33 出处:网络
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开发者_如

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消