split
uses regex so split(" + ")
will try to split on two or more continues spaces and since your String probably don't have such spaces it will not be split so parts[0]
will hold entire original String. Because of that your code will try to parse something like
Integer.parseInt("123 + 321")`
which throws NumberFormatException
because it is not correct integer this method can parse. Try escaping +
in split. You can also make spaces optional.
Try with
String[] parts = text.getText().split("\\s*\\+\\s*", 2);
Also note that you are trying to parse parts[0]
twice. Change your
temporary[1] = Integer.parseInt(parts[0]);
to
temporary[1] = Integer.parseInt(parts[1]);