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. Anyone able to get streetview working?

Is anyone able to get streetview working?

i was able to start the streetview map but the map wont display and
gave an error that says 'invalid panorama'

The only documentation about street view i can found is
http://code.google.com/android/reference/available-intents.html

    private static final String STREET_VIEW_FORMAT =
"google.streetview:cbll={0},{1}&cbp=1,0,-20,1.0&mz=test";

            GeoPoint pt = listing.getGeopoint();
            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(
                    MessageFormat.format(STREET_VIEW_FORMAT,
pt.getLatitudeE6()/1000000f, pt.getLongitudeE6()/1000000f)));
            startActivityForResult(i, RESULT_OK);
--~--~---------~--~----~------------~-------~--~----~

2. ArrayAdapter

How does the ArrayAdapter know when the array has been modified? I am
using my own adapter, and I want to add items as they come in while
asynchronously updating the ListView displaying them.
--~--~---------~--~----~------------~-------~--~----~

3. How to measure the Bytes sent and received through the 3G network

4. get position of cursor in EditText

5. commons logging - android logging

6. Do you know the Android Developers

7. Extract some information from an APK file