Duplicating this question with some modifications, as I have new info
So, from the beginning: I’ve got AutoCompleteTextView filled with ArrayAdapter:
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) header.findViewById(R.id.auto_complete_text_view);
autoCompleteTextView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, arrayList));
header – inflated view: my AutoCompleteTextView is in ListView header
XML:
<AutoCompleteTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/auto_complete_text_view"
android:hint="@string/hint"
android:completionThreshold="1"
android:dropDownWidth="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:scrollHorizontally="true"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:layout_marginLeft="@dimen/external_margin"
android:layout_marginRight="@dimen/external_margin"
android:layout_marginBottom="@dimen/external_margin"
/>
App launches, dropdownlist appears, but I can't enter more than 1 symbol (or more than specified in threshold parameter). I can't neither delete more than 1 symbol if I've chosen some option from the list.
@pskink First of all, thank you for your interest. I’ve been trying to think over your solution, but didn’t get how I would apply it considering facts below.
I’ve made some research and here’s what I’ve found:
===============================================
Idea #1: arrayList is too large for AutoCompleteTextView (~450 entries)
Solution: get sublist from original list
autoCompleteTextView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, arrayList.subList(1, 10)));
Result: view behavior remains the same
Solution: feed to adapter another array
String[] array = {“one”, “two”, “three”, “four”}
autoCompleteTextView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, array));
Result: view behavior remains the same
===============================================
Idea #2: let’s try to create test activity and place AutoCompleteTextView there
Solution:
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.auto_complete_text_view);
autoCompleteTextView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, arrayList));
Result: works perfect with initial code and with ~450 entries of arrayList
As it works as it should, I’ve come to realize that point is in ListView header
===============================================
Idea #3: google some solutions related to ListView header and AutoCompleteTextView
Android AutoCompleteTextView as ListView header
android:descendantFocusability="afterDescendants"
Result: view behavior remains the same
Focusable EditText inside ListView
Result: I think it’s not appropriate decision for my issue, so didn’t try it. At least yet
===============================================
Idea #4: perform some other actions right after dropdown list appearing Steps:
- Start typing in my AutoCompleteTextView something – as mentioned above, only one symbol is typed, dropdown list appears
- Touch screen in some other area (not dropdown list) – list disappears
- Click on input field of AutocompleteTextView again and continue typing – one more symbol can be typed, dropdown list appears
Repeating steps above, I can type something large.
===============================================
And the last one: noticed a lot of following messages in Logcat when I’m typing something in AutoCompleteTextView:
getTextBeforeCursor on inactive InputConnection
Have found some related issues, for example:
getExtractedText on inactive InputConnection warning on android
Solution:
@Override
protected void onPause() {
// hide the keyboard in order to avoid getTextBeforeCursor on inactive InputConnection
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
super.onPause();
}
Result: view behavior remains the same
I’m lost.