2012-07-16 24 views
0

我想使用Web服務填充我的快速搜索框。我有一個Web服務,將Web服務器的搜索數據放入字符串數組中。我想要顯示數據列表作爲用戶鍵入到搜索對話框中。我相信默認搜索對話框是一個簡單的EditText。我如何使它成爲`AutoCompleteTextView並使用包含我的數據的字符串數組填充它?如何使用搜索對話框實現AutoCompleteTextView

回答

0

首先,你必須從WebService分析數據,然後存儲值/數據字符串
例:其中板球隊伍將有來自Web Service的數據CricketTeams

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


更詳細的例子Here

+0

我知道如何使用'AutoCompleteTextView'。我不知道的是如何使'AutoCompleteTextView'作爲我的默認搜索對話框 – Harsh 2012-07-16 19:17:25

+0

使用'CricketTeams.getText()。toString();'從AutoComplete TextView中獲取文本,並開始搜索 – VenomVendor 2012-07-16 19:36:52

+0

哦,但那不會看起來像一個搜索對話框?當您點擊搜索按鈕時,它們也不會顯示。 – Harsh 2012-07-18 16:28:44