android:digits - Limit the Data Input to Certain Numbers Only in a TextView

How to Limit the Data input to certain numbers only in a TextView

android:digits added in API Level 1

If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will accept. If this is set, numeric is implied to be true. The default is false. 

** This code works, but I'm not sure you would need it for a TextView.

1. Add a TextView.

2. In the main.xml file, add the below line. This limits the data input to only odd numbers. No error is provided. Nothing else can be typed. 

  <TextView
    ....
      android:digits = "13579" 
  />
 
3. Compile and run!

Resources:
developer.android.com/reference/android/R.attr.html#digits
http://developer.android.com/reference/android/widget/TextView.html#attr_android:digits