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)
 http://commonsware.com 
_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
DigitsKeyListener.

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 make a custom View having it's height = width ?

Hi guy,

I'm trying to make my custom view looks like a square...
I'm putting my view in a linear layout like this :

LinearLayout
- Header view
- square view (my custom view)
- footer view

With the screen orientation set to "Portrait" *I would like my square
view to have height the same as it's width.
My custom view extends View class and override the onDraw method...

I can't figure out how to tell my view to take height=width within the
linear layout.
Is it possible using onLayout, onsizeChanged, onMeasure
And what should i do with this method

In onMeasure I guess I should tell that measuredHeight should be the
same as measureWidth wich should be equals to the linearLayout
width... but How can I be aware at this time (onMeasure) of the width
of my contentLayout (linearLayout) ?

Thx

--~--~---------~--~----~------------~-------~--~----~

2. Android tab not appearing in Eclipse

Hi all,

I installed ADT plug-in in Eclipse 3.4(Ganymede)...Under installed
software,it shows,
=>Android DDMS
=>Android Development tools
When I checked Window->Preferences,there is no Android tab.There is no
Android under Projects tab also...
I can build applications through command line without using
eclipse...So I think my Java is right.

Please help me,

Thanks in advance,
Morice

--~--~---------~--~----~------------~-------~--~----~

3. Using Picture recording creates bad memory allocation

4. Inserting Data into a Cursor?

5. Mouse Events in Browser

6. browser plugin development?

7. Dueling Activities Over the Intent's Hand in Marriage