標籤:
<MultiAutoCompleteTextView android:id=
"@+id/mulauto" android:layout_width=
"fill_parent" android:layout_height=
"wrap_content" />java:
package com.just;
import android.os.Bundle;
import android.app.Activity;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.MultiAutoCompleteTextView;
public
class MainActivity
extends Activity {
private
static
final String[]
autostr =
new String[] { "Italy" , "IT" , "item", "its" , "itseif" }; @Override
protected
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.
activity_main); ArrayAdapter<?> adapter =
new ArrayAdapter<Object>(
this, android.R.layout.
simple_dropdown_item_1line,
autostr ); MultiAutoCompleteTextView multview = (MultiAutoCompleteTextView) findViewById(R.id.
mulauto ); multview.setAdapter(adapter); multview.setTokenizer(
new MultiAutoCompleteTextView.CommaTokenizer()); } }與之前的實現不同的是在實現選擇輸入的還要設定一個分詞方式(Tokenizer);
Android實現多個詞彙連續輸入的提示