<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright (C) 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView android:id="@+id/auto_complete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
package m.usewidget;
import m.usewidget.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class AutoCompleteTextViewActivity extends Activity {
String[] res={"beijing1","beijing2","beijing3","shanghai1","shanghai2"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.autocomplete);
setTitle("AutoCompleteTextViewActivity");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line,COUNTRIES);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.auto_complete);
textView.setAdapter(adapter);
}
static final String[] COUNTRIES = new String[] {
"AA" ,"BB", "CC",
"DD", "EE", "USA" ,"FF" ,"AA1", "AA2",
"BB2", "BB1", "BB3"
};
}