Keyboard blinks when AutoCompleteTextView dropdown is shown - android

I'm using AutoCompleteTextView inside DialogFragment. When it shows a dropdown list, keyboard hides and shows again very fast, it looks like a blink.
As possible solution, I found that it happens because of
AutoCompleteTextView {
showDropDown(){
mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED);
}
}
So overriding showDropDown() in this way removes blink
showDropDown(){
super.showDropDown()
mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_FROM_FOCUSABLE)
mPopup.show()
}
But it shows dropdown above keyboard and blocks user input. Maybe someone knows better solution?

You're not going to believe this, but I am pretty sure the December 5 patch to android Q fixed this problem. I got the update this morning, and I was hoping since it was a relatively new issue that they might have addressed it. Turns out they did! I get no more flashing keyboard when using the AutocompleteTextView.

Related

AutoCompleteTextView's Suggest List overlapping with soft keyboard android

I have a AutocompleteTextView. Suggests List will appear on typing 3 characters.Suggest list size to be be fixed i.e. 8 . Every thing is working fine except the suggest list getting overlapped with soft keyboard.
I am attaching the screen shots for the same
What should be done, suggestions please.
Thanks in advance.
Try setting android:dropDownHeight

Android Edit Text Cursor Doesn't Appear

in my app I disabled the keyboard (I use now my custom keyboard) using this code:
editText.setInputType(InputType.TYPE_NULL);
Now, my problem is that the text cursor does not appear anymore in the edit text. What should I do? Any suggestion would be very appreciated.
There is an Issue opened in bug tracker Issue opened in bug tracker for this.
One of the users suggests the approach which works on "most" devices.
Briefly, all you have to do is call:
editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
for your EditText view (after you called editText.setInputType(InputType.TYPE_NULL);).
You should probably also set:
editText.setTextIsSelectable(true);
in order for text to be selectable (though in does not seem to work properly with Samsung Galaxy SIII). This method is only available starting from HONEYCOMB (api11) so keep that in mind when developing for older Android versions.
Also it is stated that your EditText should not be the first view to receive focus when activity starts (if it is - just requestFocus() from another view). Though I (personally) have not experienced any problems with this.
Rather than just using a custom view for your custom keyboard, why not implement a full-fledged IME? That will solve your cursor problem, and even make your keyboard available outside your app (if you want).
This answer has a couple useful links if you want to do that:
How to develop a soft keyboard for Android?
I really wouldn't suggest this. Writing a good full fledged IME is really hard. In addition, users come to expect functionality from their keyboard (auto-correct, Swyping, next word prediction, the ability to change languages) that you won't have unless you spend months on the keyboard itself. Any app that wouldn't allow me to use Swype would immediately be removed (bias note: I worked on Swype android).
But if you want to integrate fully with the OS as a keyboard, you're going to have to write an InputMethodService. Your keyboard would then be selectable by the user in the keyboard select menu, and usable for any app. That's the only way to get full OS integration, otherwise you'll need to really start from scratch- writing your own EditView. Have fun with that, getting one that looks nice is decidedly non-trivial.
Also, setting input type null won't disable most keyboards. It just puts them into dumb mode and turns off things like prediction.
I tried the below answer and it worked, but take care that
1) EditText must not be focused on initialization
2) when your orientation changes while the user's focus is on the editText, the stock keyboard pops up, which is another "solvable" problem.
This was mentioned in a previous answer but take care that you MUST make sure your editText element do not get focus on instantiation:
https://code.google.com/p/android/issues/detail?id=27609#c7
#7 nyphb...#gmail.com
I have finally found a (for me) working solution to this.
First part (in onCreate):
mText.setInputType(InputType.TYPE_NULL);
if (android.os.Build.VERSION.SDK_INT >= 11 /*android.os.Build.VERSION_CODES.HONEYCOMB*/) {
// this fakes the TextView (which actually handles cursor drawing)
// into drawing the cursor even though you've disabled soft input
// with TYPE_NULL
mText.setRawInputType(InputType.TYPE_CLASS_TEXT);
}
In addition, android:textIsSelectable needs to be set to true (or set in onCreate) and the EditText must not be focused on initialization. If your EditText is the first focusable View (which it was in my case), you can work around this by putting this just above it:
<LinearLayout
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true" >
<requestFocus />
</LinearLayout>

How to disable displaying "suggestions" on the Soft Keyboard

I want to turn off displaying "Suggested Words" on the soft/virtual keyboard when someone is using my application (only on certain Activities). For the default Android keyboard, this can be found under 'Settings' (under Word Suggestion Settings).
Is there a way to disable it only within your application, without requiring the user to manually go and do it? I basically want the user to type words without providing any hints.
Thanks!
When developing for 2.0+, the supposed way is setting android:inputType="textNoSuggestions" (ref).
Unfortunately, suggestions are still shown on HTC Desire 2.2 (and probably other HTC Sense devices as well).
Using android:inputType="textVisiblePassword"will not help as well as the software keyboard by HTC won't allow you to switch languages.
So I stick to android:inputType="textFilter" to disable suggestions.
You can disable suggestions on the Soft Keyboard by adding the following line in the xml -
android:inputType="textNoSuggestions"
However according to this article, it may or may not be supported by the IME (the keyboard).
If this issue occurs, the below method works for sure -
android:inputType="textNoSuggestions|textVisiblePassword"
This works for me with the stock keyboard, even on HTC with 2.2
final EditText et = (EditText) findViewById(R.id.SearchText);
et.setInputType(et.getInputType()
| EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS
| EditorInfo.TYPE_TEXT_VARIATION_FILTER);
On my 6P running Nougat, nothing worked. While it is empty the suggestion bar stays up because it has the microphone icon on the right side.
In order to get rid of that, I used fingerup's suggestion in one of the comments and it worked!
So I decided to write an actual answer so people don't miss it.
To recap here's what I've used:
android:inputType="textNoSuggestions|textFilter|textVisiblePassword"
android:privateImeOptions="nm"
inputType="textNoSuggestions|textFilter|textVisiblePassword" prevents suggestions, and privateImeOptions="nm" (stands for "no microphone") prevents the bar from showing up because it still would since the mic button is in it.
So it is necessary to use both attributes because if all you do is specify no mic then the bar still shows up with recommendations.
Thx again to fingerup for mentioning the nm trick. ;)
There are two ways that I know of to disable the auto-complete. One way is through the XML by setting the android:inputType="textVisiblePassword" in the layout xml.
The other way is through code such as the following
EdtiText editTextBox = findViewById(R.id.myEditTextView);
editTextBox.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
I was facing the same issue on Samsung devices using:
android:inputType="textNoSuggestions|textFilter|textVisiblePassword"
only after setting the inputType to password and visiblePassword worked for me:
android:inputType="textPassword|textVisiblePassword"
android:inputType="textPhonetic" hides soft keyboard suggestions on Android 1.6.
hope this works for you,
editText.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_CAP_SENTENCES|InputType.TYPE_TEXT_FLAG_MULTI_LINE|InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
If you are using InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS in activity, it will work fine.
In case of DialogFragment, you should place InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS at
onActivityCreated() handler as below :-
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
EditText editTextUsername = (EditText)dialogView.findViewById(R.id.txtUsername);
editTextUsername.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
}

AutoCompleteTextView suggestion results sticking to screen when they shouldn't

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

Android ListView item highlight programmatically

I know it's been asked around but I haven't found quite the answer yet (new to Android so sorry about the ignorance)
my app's launch Activity has an EditText (called searchbox) , a ListView (designations) and a Spinner (types)
I use the EditText as a searchbox, I have to pass the string through a custom editing to make searching more flexible. After that I match that against the closest approximation I find in 'designations' and do
designations.setSelection(j);
As expected, this sets the desired item to the top of designations. But I can't find a way to highlight it via code.
NOW, i do know that if the device is in touch mode the highlighting of a selected item won't occur. So the last 4 lines of my searchbox's onTextChanged event are:
designations.setFocusable(true);
designations.setFocusableInTouchMode(true);
if (match==true) designations.setSelection(j);
if (st.length()==0) designations.setSelection(0);
to no avail.
now, i don't have any code on searchbox's afterTextChanged(Editable s);
so could anyone give me a clue on this?
regards
~dh
check out requestFocus() and maybe requestChildFocus()
Have you tried setting the actual View to be selected?
designations.setSelection(j);
designations.getSelectedView().setSelected(true);

Categories

Resources