標籤:
package com.test.androidui;import android.app.Activity;import android.os.Bundle;import android.widget.ArrayAdapter;import android.widget.AutoCompleteTextView;public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle("AutoCompleteTextViewActivity"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, PHNOE); AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.auto_complete); textView.setAdapter(adapter); } static final String[] PHNOE = new String[] { "13612312345", "13678945612", "13578945632", "13878965412"};}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/auto_complete"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
android常用UI使用案例:AutoCompleteTextView