2

I have implemented a TextWatcher on my AutoCompletionTextView and I am trying to work with the isPerformingAutoCompletion method as a means to check if AutoCompletion successful (i.e. a match exists).

But it seems the isPerformingAutoCompletion always returns false even though autoCompletion has potential matches?

I'm using a simple array adapter with ACTV:

private void initQuickSelect()
    quickSelectAdapter = new ArrayAdapter<>(this,android.R.layout.simple_list_item_1, Items );
    acTextView = (AutoCompleteTextView) findViewById(R.id.actv_view);
    acTextView.setAdapter(quickSelectAdapter);
}

and my TextWatcher:

 private void setupTextListener(){
    acTextView.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }
        @Override
        public void afterTextChanged(Editable s) {
            if(s.length() > 0){
                Log.d("gw", String.valueOf(acTextView.isPerformingCompletion()));

            }

        }
    });
}

the debug log always returns false, any ideas where I'm going wrong?

GordonW
  • 1,120
  • 2
  • 16
  • 36
  • what is your goal anyway? what do you want to achieve? see [here](http://androidxref.com/6.0.0_r1/xref/frameworks/base/core/java/android/widget/AutoCompleteTextView.java#919) for more info and ^F `mBlockCompletion` – pskink Oct 11 '15 at 07:10
  • I has trying to add a hook to tell me exactly when the autocomplete ran out of auto complete options. – GordonW Oct 11 '15 at 08:26
  • 1
    ok, what is your data model for your ACTV? where is data taken from? – pskink Oct 11 '15 at 08:28
  • I'm using a standard array adapter see my fist code snippet above, for this I'm passing it a string arraylist. I have tried all sorts of checks within the textwatcher, my problem is that textwatcher fetches the adapter data before adapter updates therefore using any adapter functions like getCount are always lagging ghe actual view if that makes sense? – GordonW Oct 11 '15 at 11:30
  • why do you need those checks in `TextWatcher`? and why do you need `TextWatcher` at all? – pskink Oct 11 '15 at 11:42
  • The app allows the user to search for an item using the actv, as the user types a dropdown of items appears narrowing as the type more, they can tap to select an item from dropdown however if the type an item not on list (predetermined list fed as arraylist) I want a button to highlight at right of actv which if tapped will allow user to save as new item. This will then add to the predetermined list for next time. – GordonW Oct 11 '15 at 11:46
  • maybe you should look [here](http://stackoverflow.com/a/19860624/2252830) – pskink Oct 11 '15 at 11:49
  • Thanks I'll take a look now, appreciate the help. – GordonW Oct 11 '15 at 11:58

1 Answers1

3

isPerformingCompletion will return true to the watcher when the user selects one of the items offered as a completion.

It sounds like you're expecting it to return true when there are valid completions being offered. I'm not sure how to find that information.

Xiao
  • 1,552
  • 2
  • 22
  • 20
  • 1
    Ahh, that makes sense, I thought this returned true as long as there were valid auto complete outputs and false when the i.e. drop-down went empty. – GordonW Oct 11 '15 at 08:26