How to disable AutoCompleteTextView's drop-down from showing up?

前端 未结 17 1983
终归单人心
终归单人心 2020-12-05 15:30

I use the following code to set text to an AutoCompleteTextView field. But I noticed that when I set certain text (not all text, but some) to it, it will automatically pop u

17条回答
  •  粉色の甜心
    2020-12-05 15:50

    You can try these steps:

    1. When setting the text, also set the Threshold value to a large value so that the dropdown doesnot come.

       actv.setThreshold(1000);
      
    2. Then override the OnTouch to set the threshold back to 1.

         actv.setOnTouchListener(new OnTouchListener() {
                      @Override
          public boolean onTouch(View v, MotionEvent event) {
              actv.setThreshold(1);
              return false;
          }
      });
      

提交回复
热议问题