喵呜~今天要做的是一种很方便的东西喔,ww,就是那种羞羞的,啊~不是。是打一两个字就会自动弹出补全选项的输入框啊哈哈哈哈
来到miaowu.xml
<AutoCompleteTextView
android:width="match_parent"
andriod:height=“wrap_content”
andriod:id="@id/country"
android:hint=“Select your country”
/>
然后呢,来到String.xml
<string-array name="country_names"
<item>China</item>
<item>Japan</item>
<item>America</item>
/string-array>
之后来到mainActivity.java
AutoCompleteTextView autoCompleteTextView;
String [] Country_Names;
public void onCreate()
{
......
autoCompleteTextView=(AutoCompleteTextView)findViewById(R.id.country);
Country_Names=getResources.getStringArry(R.id.country_nsmes); //捕获auto_text酱和array
ArrayAdapter<String> adapter_chan=new ArrayAdapter<String>(this,android.rlayout.simple_list_item_1,Country_Names);
autoCompleteTextView.setAdapter(adapter_chan); //给auto_text酱set arrayAdapter
}