Difference between MultiAutoCompleteTextView and AutoCompleteTextView

前端 未结 4 923
情深已故
情深已故 2021-02-01 12:20

Can someone explain the difference between MultiAutoCompleteTextView and AutoCompleteTextView?

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-01 12:43

    AutocompleteTextView only offers suggestions about the whole sentence and MultiAutoCompleteTextView offers suggestions for every token in the sentence. You can specify what is the delimiter between tokens.

    String[] words=new String[] {
         "word1", "word2", "word3", "word4", "word5"
     };
    
    MultiAutoCompleteTextView macTv = (MultiAutoCompleteTextView) this.findViewById(R.id.mac_tv);
    ArrayAdapter aaStr = new ArrayAdapter(this,android.R.layout.dropdown_item,words);
    macTv.setAdapter(aaStr);
    macTv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer() );
    

    and:

    
    

    with this example the suggestion comes after every comma.

提交回复
热议问题