Reputation: 434
I have an EditText where I set a hint with
editText.setHint("Hint 1");
This works because the EditText was empty before. But now I want to change the hint so that "Hint2" is shown in the EditText.
Unfortunatelly
editText.setHint("Hint2");
doesn't work because the EditText is not empty this time.
Does anyone know a solution?
Upvotes: 0
Views: 8605
Reputation: 71
The hint change is correctly achieved with
editText.setHint("Your hint");
But it will get displayed only when the EditText
's text gets cleared with:
editText.getText().clear();
This is consistent with the purpose of a hint, i.e. give the user a hint on what to write in a text field (if already filled there's no purpose of showing an hint!)
Upvotes: 3
Reputation: 281
Have you tried setting editText.setText(null); and set the hint? After setting hint you can set the text again.
Upvotes: 4