I am currently working on Android
I have a xml which is like this:
<Point pointid =1> // first point tag
<a>
</Point>
<Point pointid =4> // second point tag
<a>
</Point>
I am fetching the pointid attribute from XML with this code:
NodeList listOfPersonsi = doc.getElementsByTagName("Point");
String p = ((Element)listOfPersonsi.item(i)).getAttribute("pointid");
here i value will be 0 for first point and 1 for second point.
I have a button called next when i click on that button I am incrementing the i value, but I want something like this if the pointid = 1 I have to perform some action and if pointid = 4 i need to perform different action.
so
if(i == 0) // i value may be 1,2...etc
{
if(pointid == 1)
{
"one functionality "
}else if(pointid == 4)
{
" another functionality"
}
}
but I want to acheive this dynamically I dont want to hardcode it as 1 and 4 to perform some action
Please help
Create a
List<Integer> pointIdsand as you parse the xml, callpointIds.add(pointId)as you find additional ids. Then modify your code to see if laterpointId.equals(pointIds.get(0)). This entire mechanism seems pointless. I’m having trouble deducing why you need this to be “dynamic”.