Reputation: 9653
Below is the code i am using for edittext which allows user to enter only numbers.
<EditText
android:id="@+id/mobileNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/mobileHint"
android:inputType="number"
android:textColorHint="@color/hintColor"
android:textColor="@color/numbertextcolor"
android:textSize="@dimen/sp16" />
To disable autosuggestions i changed
android:inputType="number"
to
android:inputType="number|textNoSuggestions"
But with this my edittext also allow user to enter special characters listed in Num KeyPad.
I want to allow user to enter only numbers with auto suggestion off.
Upvotes: 3
Views: 2138
Reputation: 11
Using android:inputType="numberDecimal|numberSigned|textNoSuggestions"
in xml wasn't working but
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
in java file worked for me.
Upvotes: 0