I would like to allow possible inputs 0-9, "," or "-" for EditText and could not find the answer.
I know using "|" as a separator is possible:
android:inputType="number|text"
But how can I archive something like this (this does not work too bad):
android:inputType="number|,|-"
Somebody knows?
Hi,
Cody
Adding to the comment below:
private class MyKeylistener extends NumberKeyListener {
public int getInputType() {
return InputType.TYPE_CLASS_NUMBER;
}
@Override
protected char[] getAcceptedChars() {
return new char[] {'0','1','2','3','4','5','6','7','8','9',',','-'};
}
}
source
share