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?
Related
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?
Let's say I have an edittext field and I have to implement "backspace" functionality on it.
Deleting a simple letter character is fine, it works:
Character.isLetter(inputConnection.getTextBeforeCursor(1, 0).toString()) {
inputConnection.deleteSurroundingText(1, 0);
}
The problem comes when the character is an emoji symbol.
Its length is expressed as 2 utf-16 chars, for an example:
Grinning face: 😀
Unicode codepoint: U+1F600
Java escape: \ud83d\ude00
In such a case, I would simply remove 2 chars.
However, there are cases where an emoji is formed by multiple codepoints, like:
Rainbow flag: 🏳️🌈
Unicode codepoint sequence: U+1F3F3 U+FE0F U+200D U+1F308
Java escape: \ud83c\udff3\ufe0f\u200d\ud83c\udf08
When I press backspace, only one java escaped char gets deleted, not whole emoji. For flag example, only this \udf08 last part would be deleted, presenting user with screwed up emoji symbol. Surrogate pair check doesn't get me out of the hole here, I would still have screwed up emoji.
How can I properly find out the correct amount of chars to remove, so I would delete 1 whole emoji when pressing backspace? (for the flag example, I would need to get the number 6, to remove it fully)
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.
I don't know if I should parse the content of the EditText field called "startTime" if the textInput attribute is set to "Time."
The input keyboard offers the "Phone Number" set of keys which doesn't quite work for entering time (i.e. I wasn't able to add a period [is present in the keyboard] or a semicolon [is missing] as in 10.55 or 10:55)
Plus, I want to know what format (12-hour vs. 24-hour) is used by default.
It's important because then the question of handeling am/pm distinction comes into the picture.
Please include how to "set/fix it" snippets of code with your answer.
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?