I want to limit input in the EditText of all symbols except figures, "?" And "*". How I am able to do it?
If you also have a maximum strict length of your string, you can use a mask. I'm not sure that it's the right solution, but it's the easiest one. An easy way use a mask in your Android programs in Android Studio is to use MaskedEditText library (GitHub link).
I can not understand what does mean: figures, "?" And "", so I suppose just "?" and "". So the code is:
In your build.gradle:
compile 'ru.egslava:MaskedEditText:1.0.5'
And in your layout:
<br.com.sapereaude.maskedEditText.MaskedEditText
android:id="@+id/phone_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:typeface="monospace"
mask:allowed_chars="?*"
mask:mask="##########"
app:keep_hint="true"
/>
This code creates an EditText that can contain ONLY "?" and "*" and max length is 10. Feel free to ask your questions :-)
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