If order of operations matter you're going to have to use a stack. If you're only calculating from left to right, you should be fine.
As @Ericson Willians answer, you convert a String to an int or double via:
String str = text.getText();
Integer.parseInt(str);
Double.parseDouble(str);
But, you're likely to run into trouble here because when you press the enter button, you are getting the entire equation you placed in your your text element, aka if you pressed enter and you had the equation stored as "2 + 3", your text.getText() will give you "2 + 3" and you will not be able to use the following without giving you an error.
Integer.parseInt(text.getText()); //NumberFormatException For input string: "2 + 3"
Double.parseDouble(text.getText()); //NumberFormatException for "2 + 3"
You're going to have to break up the string in a specific way before you can convert the strings into integers or doubles. A good way to break up the string would be to use something like:
String st = text.getText();
//Example: String st = "2 + 3";
//remove white space
st = st.replaceAll("\\s","");
//might have to change to allow for negative numbers
String[] splitStrings = (st.split("((?<=[+-/*])|(?=[+-/*]))"));
//Example: splitStrings is now -> ["2","+","3"]
This breaks up the string between operations. You can then get the elements you want and parse them as integers. So for example:
int result;
int left = Integer.parseInt(splitStrings[0]);
String op = splitStrings[1];
int right = Integer.parseInt(splitStrings[2]);
if(op.equals("+")){
result = left + right;
}
text.setText("" + result);
But, since the equation could be big, you should probably create a loop that does something like this and you're going to need an if statement or a switch statement for all the operations.