Treating the caption of the button as the actual data is something that is pretty much only acceptable practice when you're doing the digit-buttons in a calculator, so I don't know if that holds for 'android basics' ;)
Regardless;
You're stating you want to display the corresponding number, when the user presses a key (button?). And then you say getText
just shows you the content of the pressed button... Is that not exactly what you're asking for? You might need to provide a bit of code and show us what's not working the way you intended. But if a button has the text '8', and you want to treat that as an eight in mathematical operations, you need to parse it:
Integer myNumber = Integer.parse(myButton.getText());
...which will of course throw an exception if the text of myButton
does not resolve to an integer.
EDIT, AS OF COMMENT
From the explanation of your problem you gave in your comment, yes, setText()
resets the text entirely to the value it's being passed, but you can use a combination of that and getText()
if you just want to append something to the current value:
myEditText.setText( myEditText.getText() + " " + myButton.getText() );