I have a UI component that extends EditText. It watches for changes to text contents by the user with a TextWatcher.
I have a problem that only shows in Android 4.1.2:
My component (previously) selects a range of text selected programatically, using setSelection() to set start of selection and extendSelection() to extend it.
When the text is selected, the beforeTextChanged() and afterTextChanged(0 are NOT called when backspace is typed.
Entering a character at the keyboard causes the selected text range to be replaced with the type character correctly, so it appears the selection is working.
This works fine in Android 4.0.2 and other versions I have tried.
Any ideas for a workaround?
I have the same problem, the workaround I found is in the manifest, set targetSdk = 15 or lower.
Related
Pressing Enter/Submit when the user focus is in the search creates a new line break rather than submitting the search.
This appears to only happen in an emulated environment with a physical keyboard.
The text input is androidx Jetpack Compose. I added the lines:
singleLine = true,
maxLines = 1,
to the OutlinedTextField, but all that did was prevent the textbox from expanding to the next line.
You can see in the screenshot below that the cursor moves to the next line. The cursor is there and is barely visible, but the only change was that the text field no longer expands to a second row:
Search works just fine with the on-screen keyboard, so that's not the issue. The issue only seems to be with external, physical keyboards.
Use an onQueryTextChanged on the searchView, and if you see a \n inserted delete it and trigger a search
I've been thrown into trying to fix bugs in an app I didn't write, and I'm not all that familiar with Android. I'm having problems with text boxes not updating with keyboard inputs. Here's whats happening:
In android 10 (only) when I click on a text box, type stuff with the soft keyboard, nothing shows up in the textbox until the soft key board is minimized. But it works 100% fine in Android 5.1, 6, 8.1. (Also, compiling app with SDK for Android 8.1 or 10 makes no difference). The text box is never covered or hidden by the keyboard, it just remains empty until the keyboard is minimized.
The only thing that works is if I make the keyboard floating type, or if I position the textbox way at the top of the layout such that Android does not need to pan or resize the view to accommodate both the box and the default keyboard. A floating keyboard works anywhere, even partially over top of this text box.
I have tried every possible parameter combination I can find in the manifest and layout xml files, including android:windowSoftInputMode , android:fitsSystemWindows , android:isScrollContainer , android:gravity , android:paddingBottomandroid:configChanges
The fact this is -only- an issue for Android 10 is suspicious.
For anyone that finds this in the future: the issue turned out to be that hardware acceleration needed to be turned on. See EditText in Android doesn't show text when typing while using the on-screen keyboard
I'm seeing what I think is strange behavior using an EditText with inputType=numberDecimal.
On my Galaxy Nexus (using Google Keyboard), when I tap into the editText field, often times there's an underline present:
It almost looks like it could be auto correct, auto complete, or text suggest but that wouldn't make sense for a numberDecimal input type. I've tried textNoSuggestions and as expected this did not remove the underlines.
When present, these underlines are currently causing me an issue. I have a textwatcher attached as a listener on the editText. After tapping into the field, whenever this underline is present and the cursor is positioned as in the screenshot:
When a user enters a 2, onTextChanged receives: 0.002. This is correct. I then format this number to be 0.02 in afterTextChanged.
At this point if a user enters a 3, onTextChanged receives: 0.020023. This is not correct. For some reason the "002" is being appended into the editText value before the 3. This obviously throws off my formatting logic in afterTextChanged.
My textwatcher logic has been working for a long time and only recently starting having this issue. Anytime I move the cursor around, making the underline go away then I see no issues with onTextChanged receiving the "incorrect" value.
As far as what's changed to make this underline start happening, I believe I've narrowed it down to the Google Keyboard app. I see this issue when I use Google Keyboard version 1.1.1881.801980. I uninstalled updates and rolled back to version 4.2.2-573038, and with that version there are never any underlines and therefore no issues with my textwatcher.
So, my questions:
Does anyone know what this underline is supposed to be in a numberDecimal field? Is it legit or is this a bug?
Bug or not, does anyone know how to prevent this underline from ever appearing when a user taps into the field?
I have a very similar issue. Whenever I get underlined text, my text listener is getting unexpected values for the CharSequence s in onTextChanged.
Set
android:inputType="textNoSuggestions"
I think this is a bug with the keyboard remembering state for old input even after setText has been called on the EditText. I fixed it using the following code to reset the state.
InputMethodManager mgr = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.restartInput(editText);
This issue has been fixed with the latest update to the Google Keyboard app, version 2.0.18933.905102a.
So I have a form that contains two EditText components and a RadioGroup.
When I click on one of the EditText fields the keyboard pops-out and I can right and everything is great. UNTIL I click on one of the RadioButtons and it gets clicked with the keyboard still out!! And when I use the keyboard it writes in the last focused EditText( Android 4.0) while on my Galaxy S2 (Android 2.3.6) it crashes the app!!
I researched that issue and I found that it was a known issue in (Android 2.0-) so what is wrong with what I'm doing?
I want to be able to use onFocusChange listener to validate the RadioGroup selection? Any Ideas will be appreciated.
my AutoCompleteTextView is created with a custom adapter to show suggestions for ~3000 Strings. while typing in the input view, suggestions are coming up as expected, except that sometimes a chunk of the dropdown view with suggestions is being clipped or looks like its detached from the AutoCompleteTextView. this extra chunk of the dropdown apears to be holding previous suggestions that are no longer relevent. upon clicking a suggestion or typing more letters - the "stuck" dropdown piece disapears.
edit: i find that once the AutoCompleteTextView is only showing one suggestion after showing more than one, the problem occurs
Why is this happening? How can i fix it?
Right now i am trying a few things(none of which are working):
-adding a TextWatcher on the AutoCompleteTextView and invalidating the AutoCompleteTextView in the onTextChanged method.
-getWindow().getDecorView().invalidate(); on the Activity containing this AutoCompleteTextView in the onTextChanged method
edit: this is only happening on the samsung galaxy s phone running 2.1 sdk version 7