开发者

Android - Custom calculator?

开发者 https://www.devze.com 2023-03-04 23:22 出处:网络
I am writi开发者_JS百科ng a custom calculator Android app. Basically, I have five edittexts, a calculate button and a reset button. I have hooked up the reset button so that onclick of the reset butto

I am writi开发者_JS百科ng a custom calculator Android app. Basically, I have five edittexts, a calculate button and a reset button. I have hooked up the reset button so that onclick of the reset button it sets the value of all five edittexts to "".

How would I go about getting the values of all the edittexts on calculate button click and making an algorithm? Since there are five values, would I need to save each to a sort of temporary cache string?

I am really, really new to this so very plain english is preferable. Thanks for any reply.


If what you're trying to calculate is a sum, then you should iterate through the Edit Texts (which you can conveniently save in an Array or a Collection... I'd rather go for the Array actually), and, well, add it to the previous value in an auxiliary variable.

I don't get where is the problem. Maybe I'm misunderstanding something. Seeing your current code could help.

0

精彩评论

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