Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - default value in editText

In my app I have an edit user details page and I want to display the current name, email address etc in the corresponding editText fields and then the user can just erase that and enter a new one if they want.

Is there a way to do this? Thanks for any help

like image 827
user1360909 Avatar asked Apr 27 '12 10:04

user1360909


People also ask

How to set default value in EditText in android?

You can use the setHint() to set it, or set it in XML (though you probably don't want that, because the XML doesn't 'know' the name/adress of your user :) ) Show activity on this post. You can use EditText. setText(...) to set the current text of an EditText field.

How to set default text in edit text android studio?

Do this: editText. setText("Your default text");


2 Answers

There is the hint feature? You can use the setHint() to set it, or set it in XML (though you probably don't want that, because the XML doesn't 'know' the name/adress of your user :) )

like image 85
Nanne Avatar answered Sep 21 '22 16:09

Nanne


You can use EditText.setText(...) to set the current text of an EditText field.

Example:

yourEditText.setText(currentUserName); 
like image 34
aioobe Avatar answered Sep 23 '22 16:09

aioobe