【问题标题】:How to implement AutoCompleteTextView using Search Dialog如何使用搜索对话框实现 AutoCompleteTextView
【发布时间】:2012-07-15 16:22:51
【问题描述】:

我想使用网络服务填充我的快速搜索框。我有一个网络服务,它从网络服务器中提取搜索数据以放入字符串数组。我希望在用户输入搜索对话框时显示该数据列表。我相信默认的搜索对话框是一个简单的EditText。如何使它成为一个`AutoCompleteTextView 并使用包含我的数据的字符串数组填充它?

【问题讨论】:

    标签: android


    【解决方案1】:

    首先您必须解析来自网络服务的数据,然后将值/数据存储在字符串中
    示例: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

    【讨论】:

    • 我知道如何使用AutoCompleteTextView。我不知道如何将AutoCompleteTextView 作为我的默认搜索对话框
    • 使用 CricketTeams.getText().toString(); 从 AutoComplete TextView 中获取文本,然后开始搜索
    • 哦,但这看起来不像是搜索对话框,对吧?当您单击搜索按钮时,也不会出现。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-21
    • 2012-12-13
    • 1970-01-01
    • 1970-01-01
    • 2015-05-16
    • 2014-08-15
    相关资源
    最近更新 更多