// mact.setTokenizer有什么用(new MultiAutoCompleteTextView.CommaTokenizer()); //请查看代码结尾以查找此代码行
公共类MainActivity扩展了Activity {
private AutoCompleteTextView act;
private MultiAutoCompleteTextView mact;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String[] countries=getResources().getStringArray(R.array.list_of_countries);
ArrayAdapter<String> adapter =new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,countries);
act=(AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
mact=(MultiAutoCompleteTextView)findViewById(R.id.multiAutoCompleteTextView1);
act.setAdapter(adapter);
mact.setAdapter(adapter);
//******************************************************************
mact.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
的 的 ** * ** * ** * 的** * ** * ** 查找XML ** * ** * ** * ** * ** * ** * ***
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="65dp"
android:ems="10">
<requestFocus />
</AutoCompleteTextView>
<MultiAutocompleteTextView
android:id="@+id/multiAutoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/autoCompleteTextView1"
android:layout_centerVertical="true"
android:ems="10" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/auto_complete"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/multiAutoCompleteTextView1"
android:layout_alignParentLeft="true"
android:layout_marginBottom="19dp"
android:text="@string/multi_auto_complete"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>