How To Set Text In An EditText
If you check the docs for EditText
, you'll find a setText()
method. It takes in a String
and a TextView.BufferType
. For example:
EditText editText = (EditText)findViewById(R.id.edit_text);
editText.setText("This sets the text.", TextView.BufferType.EDITABLE);
It also inherits TextView
's setText(CharSequence)
and setText(int)
methods, so you can set it just like a regular TextView
:
editText.setText("Hello world!");
editText.setText(R.string.hello_world);
String string="this is a text";
editText.setText(string)
I have found String to be a useful Indirect Subclass of CharSequence
http://developer.android.com/reference/android/widget/TextView.html find setText(CharSequence text)
http://developer.android.com/reference/java/lang/CharSequence.html