2012-06-15 41 views

回答

0

代碼示例從android developer's site

public class CountriesActivity extends Activity { 
     protected void onCreate(Bundle icicle) { 
      super.onCreate(icicle); 
      setContentView(R.layout.countries); 

     ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
       android.R.layout.simple_dropdown_item_1line, COUNTRIES); 
     AutoCompleteTextView textView = (AutoCompleteTextView) 
       findViewById(R.id.countries_list); 
     textView.setAdapter(adapter); 
    } 

    private static final String[] COUNTRIES = new String[] { 
     "Belgium", "France", "Italy", "Germany", "Spain" 
    }; 
} 

得到說得簡單,它類似於列表視圖但在一個TextView加在上面或下面的文字。內容是數組列表中的內容。

相關問題