How to set a mask on an EditText widget?

by frizzo » Sat, 14 Mar 2009 15:50:37 GMT

Sponsored Links
 I'd like users to be able to enter a price (e.g. 4.49 or 10.99) and
that's all, no negative numbers or any of that.  Is there a feature
that allows me to do that?  I can't seem to find support for masks.

How to set a mask on an EditText widget?

by Mark Murphy » Sat, 14 Mar 2009 20:46:32 GMT


You can use setKeyListener() on the EditText to supply it something that
will validate the input on the fly.

Mark Murphy (a Commons Guy) 
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!


Sponsored Links

How to set a mask on an EditText widget?

by frizzo » Sun, 15 Mar 2009 05:40:38 GMT

 That sounds so VB2


How to set a mask on an EditText widget?

by Gesh » Sun, 15 Mar 2009 13:13:21 GMT


You can use the "android:numeric" xml attribute.
Or if you build the TextView in code then use the corresponding

Not sure if this will eliminate the possibility to input negative
numbers, but you simply extend the DigitsKeyListener if that is so
important to you.


Other Threads

1. How to prohibit the user install the app to the SDcard of the phone

Hi, all

Android 2.2 allow users install the app on SDcard. Developer could set
the android:installLocation ="internalOnly" to install the app to
internal memory. But I found that the user could also use the "adb
install -s " command to install the app on the Sdcard. Are there
anyone know how to force the app installed on internal memory? Another
question is: are there any API support to find the locatin where the
app is installed?
Thanks a lot.


2. compiling amr from android sources

Just a quick one.

Assuming it is technically possible, can I compile the amr enc project
and use it from jni?



3. Froyo media not mounting in time on boot-up? (works in Eclair)

4. not getting next image on clicking next button

5. adb connect works only with localhost?

6. Problem related to multiple Screen Support

7. Drawing a marker when user touch the map