使用AutoCompleteTextView控件的步骤

第一步:在布局文件中定义控件 android

<AutoCompleteTextView  布局

        android:id="@+id/actv" this

        android:layout_width="fill_parent" spa

        android:layout_height="wrap_content" pdo

        /> it

第二步:在Activity中引用 io

AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.actv); 引用

第三步:建立一个适配器来保存数据 im

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, layout

android.R.layout.simple_dropdown_item_1line,new String[] {"English""Hebrew""Hindi""German" });

第四步:将适配器与AutoCompleteTextView相关联

actv.setAdapter(adapter);

相关文章
相关标签/搜索