Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change text in EditText

I'm new to Android development, and have been able to set the text of EditText elements through XML code, but how can I do it in code?

like image 511
Martin Sikjær Olsen Avatar asked Feb 22 '23 16:02

Martin Sikjær Olsen


1 Answers

Simply call the setText() method. Here is an example:

EditText e = (EditText) findViewById(R.id.editText);
e.setText("New Text");
like image 67
slayton Avatar answered Mar 02 '23 17:03

slayton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!