Hi here the below code used to restrict or disable specific number while enter in Edittext.
You no need to use any filters or lot of lines code just using simple attribute in Edittext.
i.e using android:digits attribute you can resolve this issue
Code to restrict '0' while entering any number in Edittext.
android:digits="123456789"
Code to restrict '1' while entering any number in Edittext.
android:digits="234567890"
Code to restrict '2' while entering any number in Edittext.
android:digits="134567890"
Code to restrict '3' while entering any number in Edittext.
android:digits="124567890"
Code to restrict '4' while entering any number in Edittext.
android:digits="123567890"
Code to restrict '5' while entering any number in Edittext.
android:digits="123467890"
Code to restrict '6' while entering any number in Edittext.
android:digits="123457890"
Code to restrict '7' while entering any number in Edittext.
android:digits="123456890"
Code to restrict '8' while entering any number in Edittext.
android:digits="123456790"
Code to restrict '9' while entering any number in Edittext.
android:digits="123456780"
Code to restrict '0' while entering any number in Edittext.
Example:
<EditText
android:id="@+id/number"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="123456789"
android:hint="Enter Pin"
android:inputType="number" >
You no need to use any filters or lot of lines code just using simple attribute in Edittext.
i.e using android:digits attribute you can resolve this issue
Code to restrict '0' while entering any number in Edittext.
android:digits="123456789"
Code to restrict '1' while entering any number in Edittext.
android:digits="234567890"
Code to restrict '2' while entering any number in Edittext.
android:digits="134567890"
Code to restrict '3' while entering any number in Edittext.
android:digits="124567890"
Code to restrict '4' while entering any number in Edittext.
android:digits="123567890"
Code to restrict '5' while entering any number in Edittext.
android:digits="123467890"
Code to restrict '6' while entering any number in Edittext.
android:digits="123457890"
Code to restrict '7' while entering any number in Edittext.
android:digits="123456890"
Code to restrict '8' while entering any number in Edittext.
android:digits="123456790"
Code to restrict '9' while entering any number in Edittext.
android:digits="123456780"
Code to restrict '0' while entering any number in Edittext.
Example:
<EditText
android:id="@+id/number"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="123456789"
android:hint="Enter Pin"
android:inputType="number" >