Android programmatically disable autocomplete/autosuggest for EditText in emulator

后端 未结 12 538
鱼传尺愫
鱼传尺愫 2020-12-03 02:37

Targeting Android 2.2

I have read the answers to the following questions:

Turn off autosuggest for EditText?

Android: Multiline & No autosuggest

12条回答
  •  难免孤独
    2020-12-03 02:58

    You can use the class AutoCompleteTextView and set the adapter that contains nothing AutoCompleteTextView Class Reference

    example

     public class CountriesActivity extends Activity {
       protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         setContentView(R.layout.countries);
    
         ArrayAdapter adapter = new ArrayAdapter(this,
                 android.R.layout.simple_dropdown_item_1line, COUNTRIES);
         AutoCompleteTextView textView = (AutoCompleteTextView)
                 findViewById(R.id.countries_list);
         textView.setAdapter(adapter);
       }
    
       private static final String[] COUNTRIES = new String[] {""};
     }
    

提交回复
热议问题