1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.example.android.apis.view; 18 19 import com.example.android.apis.R; 20 21 import android.app.Activity; 22 import android.widget.ArrayAdapter; 23 import android.widget.AutoCompleteTextView; 24 import android.os.Bundle; 25 26 public class AutoComplete1 extends Activity { 27 28 @Override onCreate(Bundle savedInstanceState)29 protected void onCreate(Bundle savedInstanceState) { 30 super.onCreate(savedInstanceState); 31 setContentView(R.layout.autocomplete_1); 32 33 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 34 android.R.layout.simple_dropdown_item_1line, COUNTRIES); 35 AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit); 36 textView.setAdapter(adapter); 37 } 38 39 static final String[] COUNTRIES = new String[] { 40 "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", 41 "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", 42 "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", 43 "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", 44 "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", 45 "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", 46 "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", 47 "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde", 48 "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", 49 "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", 50 "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czechia", 51 "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic", 52 "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", 53 "Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland", 54 "Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia", 55 "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar", 56 "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", 57 "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary", 58 "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", 59 "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos", 60 "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", 61 "Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", 62 "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", 63 "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", 64 "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", 65 "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas", 66 "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", 67 "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", 68 "Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena", 69 "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon", 70 "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal", 71 "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", 72 "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea", 73 "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", 74 "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas", 75 "The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", 76 "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda", 77 "Ukraine", "United Arab Emirates", "United Kingdom", 78 "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", 79 "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara", 80 "Yemen", "Yugoslavia", "Zambia", "Zimbabwe" 81 }; 82 } 83