android - how to convert int to string and place it in a EditText? android - how to convert int to string and place it in a EditText? android android

android - how to convert int to string and place it in a EditText?


Use +, the string concatenation operator:

ed = (EditText) findViewById (R.id.box);int x = 10;ed.setText(""+x);

or use String.valueOf(int):

ed.setText(String.valueOf(x));

or use Integer.toString(int):

ed.setText(Integer.toString(x));


try Integer.toString(integer value); method as

ed = (EditText)findViewById(R.id.box);int x = 10;ed.setText(Integer.toString(x));


Try using String.format() :

ed = (EditText) findViewById (R.id.box); int x = 10; ed.setText(String.format("%s",x));