For example, there is an AutoCompleteTextView actv ;

Do you need to click on ( actv.setOnClickListener(...) ? ) To call the drop-down list showDropDown(); , at the next touch - hide, and so again in a circle - at the first touch - call, at the next hide. This touch should only be performed on actv.

The problem is that as soon as you touch actv, actv immediately makes dismiss a drop-down list and track in it - the past state of the drop-down list (hidden or not) is impossible ...

    1 answer 1

    Need something like this?

    enter image description here

    Then it will be like this:

     public class YourActivity extends Activity { private EditText dateTime; private String[] dateTimeList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); dateTime = (EditText) findViewById(R.id.create_datetime); setListIcon(dateTime, dateTimeList); } private void setListIcon(EditText editText, String[] list) { if (list.length <= 1) { editText.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); editText.setOnTouchListener(null); } else { editText.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_menu_down, 0); editText.setOnTouchListener(new TouchListener()); } } private class TouchListener implements OnTouchListener { private ListPopupWindow lpw; @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(final View v, MotionEvent event) { final int DRAWABLE_RIGHT = 2; final String[] list; if (v == dateTime) { list = dateTimeList; } else { list =null; } lpw = new ListPopupWindow(EditorActivity.this); lpw.setAdapter(new ArrayAdapter<String>(EditorActivity.this, android.R.layout.simple_list_item_1, list)); lpw.setAnchorView(v); lpw.setModal(true); lpw.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String item = list[position]; ((EditText) v).setText(item); v.setPressed(false); lpw.dismiss(); } }); if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getX() >= (v.getWidth() - ((EditText) v) .getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) { lpw.show(); return true; } } return false; } } } 

    The markup is approximate such

      <EditText android:id="@+id/datetime" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:completionThreshold="1" android:drawableEnd="@drawable/ic_menu_down" android:drawableRight="@drawable/ic_menu_down" android:ems="10" android:hint="" android:inputType="datetime" > </EditText> 
    • Thanks for the answer, but the question was all about AutoCompleteTextView . I'm just afraid that your naked editText will not provide the proper functionality, which is in AutoCompleteTextView (drop-down list functionality, etc.). I’ll put a plus, but I’ll still think whether I can apply it in my task ... - ilw
    • Yes of course. I myself wanted to do something, like your Wishlist, but did not find anything suitable, I decided to sacrifice the features of autocompletion. - Oleg A