添加过滤器的ListView有两个的TextView [英] Add filter to listview with two textview

查看:109
本文介绍了添加过滤器的ListView有两个的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的的ListView 有两个 TexView ,我填补它与此code一SimpleAdapter以下

I have a custom ListView with two TexView, I fill it with a SimpleAdapter with this code below

adapter = new SimpleAdapter(this, list,
            R.layout.activity_lista_vehiculo,
            new String[] { "value1","value2" },
            new int[] {R.id.line_a, R.id.line_b});      
    setListAdapter( adapter );

我怎么可以把一个过滤器,它从的EditText 搜索查看

推荐答案

SimpleAdapter 有一个内置的 SimpleFilter 该过滤器的的ListView适配器的有preFIX内容。如果这是你想要的,你可以使用下面的code做过滤工作:

SimpleAdapter has a build-in SimpleFilter which filters the content of your ListView adapter with a prefix. If this is what you want, you can use the following code to do the filter work:

            yourEditText.addTextChangedListener(new TextWatcher() {

                @Override
                public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
                    // When user changed the Text
                    yourSimpleAdapter.getFilter().filter(cs); 

                }

                @Override
                public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                        int arg3) {

                }

                @Override
                public void afterTextChanged(Editable arg0) {

                }
            });

这篇关于添加过滤器的ListView有两个的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆