如何通过搜索的文本编辑列表视图 [英] how to searchable list view through Edit text
本文介绍了如何通过搜索的文本编辑列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好我想开发应用程序,它在数组列表和一个文本编辑很多项目使用搜索项快速列表视图中我告诉ü这样的形象:
hello everyone I want develop application which have many item in array list and one Edit text for using search item fast in list view I show u image like that:
这样怎么可能在页
推荐答案
您需要addTextChangedListener添加到您的EditText。当用户在EditText上一个新的数据,从中获取文本并将它传递给阵列适配器过滤器。
您可以添加这样的:
You need to add addTextChangedListener to your EditText. when user enters a new data in EditText , get the text from it and passing it to array adapter filter. you can add like this :
inputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
// When user changed the Text
MainActivity.this.adapter.getFilter().filter(cs);
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});
完整的例子就是这里
这篇关于如何通过搜索的文本编辑列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文