Android基礎篇之AutoCompleteTextView

 2011-04-25 11:00:04

    AutoCompleteTextView 是Android中輸入提示框 雖然現在的輸入法越來越強大,但還是讓用戶輸入越方便越好

下面來看看代碼

1.在main.xml中創建一個 AutoCompleteTextView 佈局

 

 

 

 


2.爲 AutoCompleteTextView 中的數據提供佈局res/item_list.xml

 

3.AutoCompleteText.java

 

在 ArrayAdapter中爲AutoCompleteTextView提供數據源的另一種方法是在string.xml中添加string-array 如


 

獲取數據

String[] countries = getResources.getStringArray(R.array.countr);

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.item_list ,country );

 

 

 

 

 

 

 

 

 

 

 

 

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章