package com.example.demo;
import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.MultiAutoCompleteTextView;
public class AutoTextDemo extends Activity { String[] items = {"SM3", "SM5", "SM7", "SONATA", "K3", "K5", "K7", "SOUL", "SORENTO"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.autotext_demo); //AutoCompleteTextView - 자동완성 1개만 해줌... AutoCompleteTextView auto1 = (AutoCompleteTextView)findViewById(R.id.autotext1); auto1.setAdapter(new ArrayAdapter<String>( this, android.R.layout.simple_dropdown_item_1line, items )); //MultiAutoCompleteTextView - 자동완성 여러개 해줌... MultiAutoCompleteTextView auto2 = (MultiAutoCompleteTextView)findViewById(R.id.autotext2); auto2.setAdapter(new ArrayAdapter<String>( this, android.R.layout.simple_dropdown_item_1line, items )); auto2.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); } } |