需要帮助AutoCompleteTextView搜索
问题描述:
我已经实施AutoCompleteTextView
搜索。所有SDK版本和目标都支持AutoCompleteTextView
,因为当我尝试这sample 它显示一个空的下拉列表。当我在我的应用程序中使用相同的解析内容放置在一个字符串数组中时,我得到一个异常。需要帮助AutoCompleteTextView搜索
Log.v("Length of a",Integer.toString(a.length));
try{
wv.setVisibility(View.GONE);
place_list.setVisibility(View.VISIBLE);
Log.v("Length of a222222",Integer.toString(a.length));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(Bru_Maps.this, android.R.layout.simple_dropdown_item_1line, a);
textView.setAdapter(adapter);
} catch(Exception e) {
Log.v("Error","search_name"+e);
}
上面给出的代码很好地打印日志,但它返回NullPointerException
。
ArrayAdapter<String> adapter = new ArrayAdapter<String>(Bru_Maps.this, android.R.layout.simple_dropdown_item_1line, a);
答
从示例中可以看出,如果希望在TextView中键入第一个字符后查看可用国家/地区列表,则需要将阈值设置为1。使用autoCompleteTextView.setThreshold(1)
即可看到它的行动。
答
不能添加评论,所以...什么是一个数据类型?你写道它是一个字符串,当它需要是一个字符串数组。
感谢老兄..我明白了 – 2010-10-26 09:18:43