问题描述
- 如何在SearchDialog中实现TextWatcher
-
我需要根据SearchDialog
中的用户输入来更新ListView
,这样的话就需要给SearchDialog
设置一个TextWatcher
。如何实现这个功能呢?
解决方案
你可以照下面做:
yourEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// process new items for list view
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// push new items into adapter and call notifyDataSetChanged() on it
}
});
时间: 2024-10-07 02:47:17