gkotla gkotla - 1 year ago 85
Android Question

how to put hint to edittext

I have two edittext input box. First one is for username and the second one is for password. I want put hint on the inputbox. I have wrote hint with settex() method. In addition, I have wrote

in onclick(view v)


in oncreate

text1 = findViewById(R.id.editText_1);

whenever I have click on the input box, hint should dissappear. But, hint is not dissappeared. Now, is the way I am doing wrong? Or I have missed something?

Answer Source



instead. setHint() provides the hint that disappears when the user types something. You can also use a String resource ID or an xml based approach, but in your case, using the String method will suffice.

Only use setText() when you want to put text in the EditText that the user can modify.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download