If you need a number without the +/- sign or the decimal sign, set
inputType to "number" (but not numberSigned or numberDecimal).
Behind the scenes, EditText uses these interfaces to filter input:
http://developer.android.com/reference/android/text/method/KeyListener.html
http://developer.android.com/reference/android/text/InputFilter.html
The key listener can be set with TextView.setKeyListener.
Normally, this is done automatically by the framework, depending on
inputType, such as:
http://developer.android.com/reference/android/text/method/DigitsKeyListener.html
... but you can create your own classes for more flexibility:
http://kmansoft.wordpress.com/2011/02/27/an-edittext-for-entering-ip-addresses/
Note that if the IME goes into the full screen, "extracted" mode (e.g.
when the device is rotated to landscape), the listener is not called for
each keypress - so you still need to validate the entered string at the end.
You can use this method to tell the user about data entry errors in a
very nice way:
http://developer.android.com/reference/android/widget/TextView.html#setError(java.lang.CharSequence)
<http://developer.android.com/reference/android/widget/TextView.html#setError%28java.lang.CharSequence%29>
-- Kostya
01.09.2011 17:50, TreKing ?????:
On Thu, Sep 1, 2011 at 8:23 AM, Conrad <[email protected]
<mailto:[email protected]>> wrote:
Sorry for not being explicit here - I already did that, and I
could not enter a non-number. But I'm sure I didn't test
exhaustively. It would be nice if this were stated explicitly one
way or the other in the docs.
Ah, well short of someone with this knowledge chiming in, your next
best option is looking at the source.
-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
Kostya Vasilyev
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en