Is there any way to limit users allowed to type only some selected character set (Eg: A or B or C or D) in Android layout.xml
First, you can simply have it so that if the EditText block is empty, it is immediately repopulated with a "/" char. Alternatively, make it so that if the previous char is / , then prevent the user from deleting back.
What should I set to disable EditText? It's possible to preserve both the style of the view and the scrolling behaviour. To disable an EditText while keeping this properties, just use UI. setReadOnly(myEditText, true) from this library.
Use the digits
attribute, only the characters passed to digits
will be allowed in the EditText.
android:digits="abc123"
And yes, "digits" is a misleading name, it accepts letters and symbols too.
You can use the inputType
attribute:
<EditText android:id="@+id/edit_text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number" />
Possible Values for android:inputType
attribute in edit text are: none, text, textCapCharacters, textCapWords, textCapSentences, textAutoCorrect, textAutoComplete, textMultiLine, textImeMultiLine, textNoSuggestions, textUri, textEmailAddress, textEmailSubject, textShortMessage, textLongMessage, textPersonName, textPostalAddress, textPassword, textVisiblePassword, textWebEditText, textFilter, textPhonetic, textWebEmailAddress, textWebPassword, number, numberSigned, numberDecimal, numberPassword, phone, datetime, date, time
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