Pre-formatted input in Kotlin - android

I'm trying to create a EditText input in Android Studio where the user enters a serial number, which is formatted as:
123456-78
What I'd like to do is make it so the user doesn't have to type the '-' character, and it is already displayed in the input field as they're typing. How can I achieve that?

Related

Input type = Registration number

How do I set the input type for registration number. For example my university has specific format for registration number i.e. CIIT/SP17-mcs-044/Atk. I want CIIT/ATK is written already and Sp17-mcs-044 as a hint.
You can't define a random types of input type. You can only have one of these types as inputType.
If you want any custom behaviour, you might use TextWatcher and validate it
As #Tim has stated, the input type would be text over here and when user types in that EditText then check if the input is correct by using RegEx, and then show any message when the input is correct, for that you will need to add an OnTextChangedListener, about which you can learn more on official documentation.
Now, CIIT/ATK can be a TextView placed right before the EditText so it will be written already and will be uneditable. And yes, add that in final string after getting the input, like this:
finalInput = "CIIT/ATK" + input;

format edittext input price format

When we work with the currency we need to use ',' separator in appropriate places . For example 1500 as 1,500.
I have a issue. My applications require formatting the EditText's value while typing. I.E., a number that needs to be formatted with decimal and thousands separators. Example, I input 123456789, the EditText display 123.456.789.
How to I do this issue ? Thank all.

Android 3.2 InputType Number Preselection

I have an EditText-Object in my Android App where the user can input a "street number". Because street number may also consit of characters, character input should not be disabled at all, rather it numeric input should just be preselected and if the user wants he can also switch to character input.
Until now I could not find any combination of Flags using
editText.setInputType(...);
Possible allowed entries in the EditText would be:
23a-26b
This always disallows some other input type, but what I want is just a preselected inputType.
Any ideas?

Numeric password field using Android webview

I'm using a webview to allow users to login. Since the site requires a numeric password, I'd like the webview to pop up the numeric keypad, but also hide the input characters. I know that if you specify an HTML input type = "number" it will pop up the numeric keypad. In addition, if you specify the HTML input type = "password" it will hide the input characters.
However, in this case, I need to do both (ie. pop open the numeric keyboard AND hide the input characters). I know that if I were using a native screen, I could specify an EditText field of type "numeric password", however, I'm using a webview, so I don't believe this is available.
Any suggestions here?
You can make it "password type", with hint for user that just numeric passwords will be accepted. When user enter password, you check from code is it numeric, in case it isn't you can show dialog that entered password doesn't satisfies criteria and make user enter valid one.
is it acceptable for your situation?

Android xml phone number in keyboard restriction

Hi in my project i have a edit text box, where i want the user to enter his phone number, I need it in a format like +0000000000 no need to allow - or any other symbols. I need to restrict the user while entering in keyboard. I have implemented the regular expression for validation for this format and I am using android:inputType="phone" is there any other input Type is available or can i customize it in any way. Looking for help pls...
Try it android:digits="+0123456789"
try this::
android:inputType="number"
it allow user to enter only integer value

Categories

Resources