0

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:

  1. Start typing in my AutoCompleteTextView something – as mentioned above, only one symbol is typed, dropdown list appears
  2. Touch screen in some other area (not dropdown list) – list disappears
  3. 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.

Community
  • 1
  • 1
Anton
  • 449
  • 2
  • 7
  • 20
  • whats wrong with it: http://codeshare.io/sQzRU ? – pskink Aug 28 '15 at 12:33
  • BTW whats the reason of using ACTV as a ListView's header??? – pskink Aug 28 '15 at 16:38
  • @pskink tried to run that snippet on emulated device: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS And about header: there's not only one ACTV in header, there are a lot of views as activity is essentially one listview with header and footer. And I need all that scrollable. I had a choice: write some sort of NonScrollableListView or use headers. I've chosen headers. It was all right till now. – Anton Aug 28 '15 at 18:28
  • so add android.permission.READ_CONTACTS permission, i used contacts as the example to show anything in the list view without populating any database – pskink Aug 28 '15 at 18:42
  • it was the first thing that I did. For some reason it didn't help – Anton Aug 28 '15 at 18:46
  • so wait for another answer – pskink Aug 28 '15 at 19:16
  • @pskink thanks a lot for your efforts! :) – Anton Aug 28 '15 at 19:20
  • btw this should work: ... – pskink Aug 28 '15 at 19:23
  • @pskink as I mentioned above, it was the first that I did. WRITE_CONTACTS didn't work as well – Anton Aug 28 '15 at 20:43
  • its funny that something which works for me doesn't work for you... how can you do any android development if you are unable to setup basic app's permissions in the manifest? – pskink Aug 29 '15 at 07:06
  • it's a bit out of scope, but will answer: I do not need any parmissions in my App. – Anton Aug 30 '15 at 07:44
  • ok of course you don't need: that was **just example** – pskink Aug 30 '15 at 07:45
  • having the same issue with autocompletetextview. I get "getTextBeforeCursor on inactive InputConnection" when selecting an item from the dropdown list. In addition, no text will appear in the textiew for the selecteditem even though the selected item is not null. (I verified the correct item was indeed selected) – dss Feb 03 '16 at 04:35

0 Answers0