0
我已经写了autocompletetextview一些代码自定义对话框box.When键入一些文字,文本搜索动态进入hashmap.This HashMap的是大线text.It works.But慢慢给我造成的。动态自动完成textview缓慢显示,如何显示更快?
AutoCompleteTextView searchText = (AutoCompleteTextView)searchDialog.findViewById(R.id.searchText);
if(searchText.getText()!=null){
// searchString = searchText.getText().toString().trim();
String[] autoList = getAutoCompletWords(searchText.getText().toString().trim());
ArrayAdapter<String> adapter = new ArrayAdapter<String>(ctx,android.R.layout.simple_dropdown_item_1line,autoList);
searchText.setAdapter(adapter);
}
private String[] getAutoCompletWords(String text){
Set<String> wordsSet = new TreeSet<String>();
Pattern wordPattern = Pattern.compile("\\b"+text+"\\w+",Pattern.CASE_INSENSITIVE);
Matcher matcher = wordPattern.matcher(bookContentMap.values().toString());
while(matcher.find()){
wordsSet.add(matcher.group());
}
String[] wordsArray = wordsSet.toArray(new String[0]);
return wordsArray;
}
如果我采取上面的代码是给我线程处理器exception.Please给我上autocomplettext列表的快速响应的想法线程。
Rajendar是
其实iam使用treeset来排序项目,同时避免重复 – ADIT 2010-11-08 12:55:58
@ user486216噢好吧。创建字符串也可能相当密集。我会编辑并添加 – 2010-11-08 13:00:45