Search code examples
androidautocompletetextview

Show AutoCompleteTextView on the first click


I'm using the AutoCompleteTextView to show a dropdown list when the user enter a word , but I would like the dropdown list to show when he first tap in the field. Maybe it would be better with a spinner but I would have no text input...


Solution

  • Just call autoCompleteTextView.showDropDown() in onTouch method.

    mAnswer.setOnTouchListener(new OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (event.getAction() == MotionEvent.ACTION_DOWN) {
                        mAnswer.showDropDown();
                    }
    
                    return false;
                }
            });