【问题标题】:ListView filter for android安卓的 ListView 过滤器
【发布时间】:2011-12-30 20:13:01
【问题描述】:

我有一个适配器,并且我使用 ad.getFilter().filter(s); 过滤列表视图。
如果我在 EditText 中写一个单词,效果会很好。
如果在一个单词后写一个空格字符,它将不起作用(结果没有行)。
例如,我想做一个带有名字和姓氏的过滤器。 我想在edittext中插入"Mario Rossi"并得到结果.. 我希望我能解释一下。
非常感谢。

private TextWatcher filterTextWatcher = new TextWatcher() {

    public void afterTextChanged(Editable s) {
    }

    public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
    }

    public void onTextChanged(CharSequence s, int start, int before,
                int count) {
        ad.getFilter().filter(s);               
    }

};

【问题讨论】:

标签: android listview filter adapter


【解决方案1】:

你的代码很完美,但有一些小错误

private TextWatcher filterTextWatcher = new TextWatcher() {

        public void afterTextChanged(Editable s) {
              ad.getFilter().filter(s);
        }

        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before,
                int count) {


        }

    };

【讨论】:

    猜你喜欢
    • 2013-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-17
    相关资源
    最近更新 更多