2012-07-16 56 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