In my application I have to validate the EditText. It should only allow character, digits, underscores, and hyphens.
EditText
Here is my code:
edit
A solution similar to the android:digits="0123456789*", is to use this:
android:digits="0123456789*"
EditText etext = new EditText(this); etext.setKeyListener(DigitsKeyListener.getInstance("0123456789*"));
An added bonus is that it also displays the numeric keypad.