Android: numbers problem

I use the following xml to restrict the input of numbers only in EditText widgets. The android: digitits attribute uses the resource below the array. Everything works fine, except that I cannot enter the number 4, even if it is in an array. Any ideas?

<EditText android:id="@+id/mynumber" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="40dp" android:textStyle="bold" android:gravity="center_horizontal" android:layout_centerHorizontal="true" android:textColor="#aaffaa" android:numeric="integer" android:digits="@array/digits" android:background="#00000000" android:inputType="phone" android:focusable="true" android:singleLine="true" /> 

The output of a string array resource:

 <string-array name="digits"> <item>0</item> <item>1</item> <item>2</item> <item>3</item> <item>4</item> <item>5</item> <item>6</item> <item>7</item> <item>8</item> <item>9</item> </string-array> 
+4
source share
1 answer

android:digits should be a string value , see http://developer.android.com/reference/android/widget/TextView.html#attr_android:digits . When using a string-array it will compile, but not work properly, as a result of which random numbers will be missing from the input.

+2
source

Source: https://habr.com/ru/post/1311031/


All Articles