How to set Adapter to Auto Complete Text view?

前端 未结 2 675
忘了有多久
忘了有多久 2020-12-20 16:39

I need adapter data set to the auto complete text view in android .

2条回答
  •  甜味超标
    2020-12-20 17:34

    Create an array of String or get it from any function and create an ArrayAdapter of String then let the adapter to set the list for you .

     String[] array={"first","second item" ,"third item"};
     AutoCompleteTextView textView;
    
    ArrayAdapter adapter;
    
    textView = (AutoCompleteTextView) findViewById(R.id.et_search);
    
    
    adapter = new ArrayAdapter(PlayListActivity.this,
                            android.R.layout.simple_list_item_1, array);
    
                    textView.setAdapter(adapter);
    

提交回复
热议问题