开发者

How to pull data from XML and then extract the data

I'm very new to Android development and Java. This is probably a simple answer but I cant seem to f开发者_开发问答ind the info anywhere. I know I can pull data from my XML by using:

Double.parseDouble(example.getText().toString());

but what I need to to is then extract the data and add it together.

Example: I pull the data and its 1234 then I need to add 1+2+3+4. Thanks for the help.


I'm not sure I understand the question, but if you want to add all the digits in a string then you would do this:

(pseudocode)

length = number of characters in string

runningtotal = 0;

loop through all charcaters in string, 0 to length-1

extract character at each loop position

runningtotal += Integer.getString(character);

But I suspect this is not actually what you're trying to do. More info?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜