Question

I am working on android and reading values from xml by parsing it. But now i have a question. I want to change textview text when clicking next button. And text will change with respect to xml file. For example,

   <questions>
        <question>
          <id> 1 </id> 
          <text>Question1</text> 
        </question> 
        <question>
          <id> 2 </id> 
          <text>Question2</text> 
        </question> 
        <question>
          <id> 3 </id> 
          <text>Question3</text> 
        </question>  </questions>

if this is my xml file, i want to update textview each time when i click the next button. I could not do it, can somebody help me?

Était-ce utile?

La solution

To start, I would parse your XML data. Create an "Question" object to store your data. Then store the Question objects in an arrayList. When you click the "next" button, find the id for the question you want and update the textview from the arrayList. Also, check out this topic on parsing XML data.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top