我需要根據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
}
});