2. MainActivity.java
package org.me.android_autocompletetextview; import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; public class MainActivity extends Activity { private AutoCompleteTextView autoComplete; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); autoComplete = (AutoCompleteTextView) findViewById(R.id.autoComplete); String[] phone = new String[]{"0986254878","0985225787","098525879","0985012486","0985658745"}; //设定自动填入的文字内容 ArrayAdapteradapter = new ArrayAdapter (this,android.R.layout.simple_spinner_item,phone); autoComplete.setAdapter(adapter); } }
3. main.xml(Layout)
"
4. 在「自动填入文字框」输入文字之後出现的画面。
沒有留言:
張貼留言