I would like to know if it’s possible to add 2 or more numbers from within a textview, the best example i could think of is the stock android calculator. i have attached pictures of my app the first picture is where the app works perfect


i would also like my app to do this (by adding 25+25 OR 25-5
i get a foreclose when i initiate the operation by clicking calculate.
could anyone please help me with this?? i have searched everywhere for the answer W/O any luck.
thanks
Since you didn’t post complete minimal code necessary to replicate the problem, I’m just guessing that you’re getting the input as type String or CharSequence, and then you’re trying to immediately turn it into a number, without first parsing it for the different parts.
Here’s a simple example of parsing String input similar to what you’re proposing to handle. Note that I am not at all suggesting that this is how you should handle your inputs. (I’m just planting a seed.) In fact, parsing string inputs for calculator functions is a very popular topic for which many examples and different approaches can be found by Google searching. (Also, note that some more “robust” calculator parsing functions will break the input into a tree or stack of operators and operands.)