//ActivityAutoCompleteTextView.java
package android.ActivityUI;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class ActivityAutoCompleteTextView extends Activity{
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.auto_complete_text_view);
setTitle("AutoCompleteTextView");
ArrayAdapter <String> adapter = new ArrayAdapter <String>(this,
android.R.layout.simple_dropdown_item_1line,Countries);
AutoCompleteTextView textView = (AutoCompleteTextView)findViewById(R.id.auto_complete_text_view);
textView.setAdapter(adapter);
}
static final String[] Countries = new String[] {
"China","Russia","Germany","Ukraine","Belarus","USA","China1","China2","Germany","Russia2","Belarus","USA"
};
}
//auto_complete_text_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<AutoCompleteTextView
android:layout_height="wrap_content"
android:text="AutoCompleteTextView"
android:id="@+id/auto_complete_text_view"
android:layout_width="fill_parent">
</AutoCompleteTextView>
</LinearLayout>