我需要根据SearchDialog
中的用户输入来更新ListView
,这样的话就需要给SearchDialog
设置一个TextWatcher
。如何实现这个功能呢?
如何在SearchDialog中实现TextWatcher
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答
- xiaoyan_12 2013-02-27 03:30关注
你可以照下面做:
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 } });
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报