Roman Fedoruk Roman Fedoruk - 2 years ago 147
Android Question

How to make the default value of a editText 0 but have it disappear when a user wants to type something int?

So basically, if the user doesn't use this edittext, then the default value stays at zero. But if they want to type something in, the zero disappears as soon as they start typing.

I have tried using:


But that doesn't affect the default value.

And when I use:


That sets the value of the editText as 0, but you have to manually delete the zero and then start typing in the number that they want to enter.

Answer Source

To achieve that I would do this: Keep the hint attribute for ui and maintain the default value programmatically:

    //set the value as zero
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download