Paul,
You could use an key listener:
http://developer.android.com/reference/android/widget/TextView.html#setKeyListener(android.text.method.KeyListener)
Here is an example for entering IP addresses:
http://kmansoft.wordpress.com/2011/02/27/an-edittext-for-entering-ip-addresses/
Note that the key listener can be bypassed if the IME goes into
"extracted" (full screen) mode, so you should keep your regexp check.
-- Kostya
25.03.2011 18:45, Paul пишет:
I have an EditText that allows the user to enter a filename, and I am
restricting certain characters being used, such as / \ ?, etc.
Currently, I allow the user to enter anything they want, then before
committing the filename, run it through a regexp checking for invalid
characters. If any are found, the EditText remains active, and the
user is shown a Toast with a message about using only valid
characters, and a list of invalid characters. Since I know ahead of
time which characters I will accept, a better solution would be to
simply remove or disable them on the virtual keyboard (an continue to
do a final regexp in case the characters were generated from an
external keyboard).
I've searched, but can't find anything specific to removing/disabling
specific virtual keyboard characters. Is this possible?
I found this post on StackOverflow that metions using one of a
TextWatcher or InputFilter, but those seem to largely operate AFTER
input, rather than preventing it in the first place, which is really
what I am after.
Thanks for any pointers, or a quick 'not possible' if that is the
case.
Paul
--
Kostya Vasilyev -- http://kmansoft.wordpress.com
--
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