I am using the android:digits option in my xml file:
android:digits="0123456789qwertzuiopasdfghjklyxcvbnmQWERTZUIOPASDFGHJKLYXCVBNM"
When I input some characters and press the space-bar more than once from my device keyboard, then the space-bar works as a back-press event and is removed from the last character. But this should not work like this.
I don't want to allow white space and special characters in the edit text.
For Ex.
I am input text and again press spacebar more than one times then start remove from last character of word.
For ex. I was input "Hello" and i was press spacebar more than one time then "o" is removed from "Hello" did same process again.
I don't know how is it..
Your problem is most likely connected with soft keyboard "suggestion". You can add following property in XML.
android:inputType="textFilter|textNoSuggestions"
This made EditText behaving as expected in my case.
Related
I have a very weird, but consistent bug in my app with any standard Android keyboard that supports word predictions.
What I’m doing is that I call InputMethodManager.restartInput() after I evaluated the input of an EditText to show a different IME label (I check the current text with a TextWatcher and the set the label to ”Close” when the text is empty and to “Send” when it's not). Without calling restartInput() the IME label change is not taken over until the connection is otherwise renewed, e.g. by closing and reopening the keyboard again.
Now when I manually enter characters through the keyboard everything is fine as expected, labels are changed, key strokes are accepted, all good, but if I click on one of the predictions on some keyboard to paste the word, the second click on the prediction is lost (i.e. the word that should be pasted after I called restartInput()).
"Lost" means different things for different keyboards, SwiftKey for example keeps the first word underlined and then replaces that with the second word on click, while Google's keyboard just keeps the first word, ignores the second word completely and then continues with any next word.
This video shows the issue: https://puu.sh/v0WUo/8f9b3571ed.mp4
I click on “Test and the”, but the EditText only receives “Test the".
Has anybody seen this before? What am I doing wrong?
I have an EditText. I am using this for entering the mobile number of different countries. As soon as the user starts entering the number , i start formatting it based on the country of the number . For example for indian number i show it as
98765 43210 , i.e a space after fifth character. Similarly for other countries i use different formatting patterns.
But at the time of deleting the number from the keypad i am facing an issue. When the user clicks backspace on softkeypad , one character gets deleted.As i am overriding the AfterTextChanged method of EditText , so it gets called . In this method i check if the formatting is disturbed due to erasing the character . And i try to reformat the remaining number , and set the reformatted text again on edittext. This works properly.
But when user longpresses the backspace in order to delete the entire phone number in one go ,Then there is a problem as described below:
Keypad's backspace is pressed (So focus is on keypad), one character got deleted, AfterTextChanged got called , In AfterTextChanged method, I reformatted the text and set the reformatted text again on edittext using editText.setText(String), As i set the text, focus went to edittext , keypad lost the focus .so keypad is no longer pressed. (I can see the keypad backspace getting unpressed on UI after one character is deleted. Even though i have not lifted the my finger from backspace)
As a result it deleted only one character and stopped.
I know if the donot set the reformatted text on the editText in AfterTextChanged, then longpress will work and is working. But i need to set this text to show dynamic formatting of number .
But i also want to delete the phone number in one go , when the user longpresses the backspace of softkeypad.
Please help me how can i achieve this.
Use the setOnLongClickListener or compare your character length once the backspace is pressed to the previous value and ignore your AfterTextChanged event?
I have an EditText box and I want the default keyboard that comes up when it is selected to be the numeric keypad. However, I do want to allow users to enter alphabetic characters too. The solutions android:inputType="number" , et.setRawInputType(InputType.TYPE_CLASS_NUMBER)...etc does not work for me because restricts input to numeric digits only. Does someone know some solution??
Add the following line of code, and it will do the trick :)
editText.setRawInputType(Configuration.KEYBOARD_QWERTY);
This will show the the numeric keypad first, but also allows you to enter free text.
More information tap here
This problem is similar to the this.
My application has two requirements where one screen is an numeric entry and other has an search option. Since user has to use the numeric keyboard most of the time he has to change the input type of edit text and select the keyboard. Is there any way i could start a numeric keyboard for one activity and charater keyboard when other activty starts
Sebs
hiii,,,
Use for the edit text that should open a numeric keypad with following property:
android:inputType="phone"
And android:imeOptions="actionSearch" for other activity Edit Text xml layout
Hope you would be able to get what I mean to convey
With Regards,
Arpit Garg
To just get a numeric keyboard the user should not have to longpress and choose input type. That would be only if they are trying to change which actual keyboard application they are using, for instance switching from Android Keyboard to Swype keyboard. All of the different configurations of keys are all part of each keyboard separately. So the Android keyboard contains a qwerty keyboard, a number keyboard (which has numbers across the top row and symbols on all the other keys) and a Number pad keyboard (9x9 block of numbers like the numpad on your PC, or an old telephone). To tell the system which you'd like to use you just have to specify the inputType for your EditText.
this page will show you possible types
this question will show you how to set it from xml
Is it possible to have Android's numeric keypad display for an EditText (the one that would show with inputType="number"), while still having an option for users to switch back to the normal QWERTY keyboard?
My input field will usually be a number, but there will be times when text is necessary so I'd like to make it very easy to enter numbers, and extremely simple to switch over to entering text.
Thanks!
Yes, you can programatically change the keyboard being used by using the setInputType() method. So for instance, you could add a button in your UI that changes the input type from just pure numbers to a full on QWERTY keyboard.
Try this. It should leave the button on the on-screen keyboard that lets you toggle between letters and numbers.
In xml, don't constrain the input--just leave it to the default of letters. (Not sure if this matters.)
mEditText.setRawInputType(InputType.TYPE_CLASS_NUMBER);