android:digits property of AppCompatEdittext not working properly as I aspect.
My XML
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="12345" />
But when I press number 6,7,8,9,0 previous characters repeated? I don't know what's wrong with this?
Add inputType="number":
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="12345"
android:inputType="number"/>
At first you should add android:inputType="number"
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="12345"
android:inputType="number"/>
Secondly
private final TextWatcher mTextEditorWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
public void onTextChanged(CharSequence s, int start, int before, int count)
{
// Logic in here
.setKeyListener(DigitsKeyListener.getInstance("12345"));
}
public void afterTextChanged(Editable s)
{
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With