I have a a EditText field which allows only decimal numbers. How can I set it's value in the code when I press a button?
Asked
Active
Viewed 175 times
2 Answers
0
You have quite a few ways to set the proper value in your EditText
. Assuming you have it's @id
being my_edittext
:
final Integer value = 10;
final EditText myEditText = (EditText)findViewById(R.id.my_edittext);
myEditText.setText(value.toString());
myEditText.setText(Integer.toString(value));
myEditText.setText(String.valueOf(value));
// and an ugly one:
myEditText.setText(value + "");

rekaszeru
- 19,130
- 7
- 59
- 73