Immediately show autocomplete on Android

后端 未结 6 2243
鱼传尺愫
鱼传尺愫 2021-02-19 05:39

The Android autocomplete only starts after two letters. How can I make it so the list appears when the field is just selected?

6条回答
  •  Happy的楠姐
    2021-02-19 06:22

    To get the autocomplete to show on focus add focus listener and show the drop down when the field gets focus, like this:

    editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
      @Override
      public void onFocusChange(View view, boolean hasFocus) {
        if(hasFocus){
          editText.showDropDown();
        }
      }
    });
    

    Or just call editText.showDropDown() if you don't need the focus part.

提交回复
热议问题