开发者

how to do filter search

I got a listview containing eventName, dat开发者_运维问答e, time, venue and event description. but i only want to search for eventName and date. Right now, i only have

listview = (ListView) findViewById(R.id.listview);
        edittext = (EditText) findViewById(R.id.search_box);
        arrayA =  new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, event); 

        listview.setTextFilterEnabled(true);  
        listview.setAdapter(arrayA);

         edittext.addTextChangedListener(new TextWatcher() {

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

             // TODO Auto-generated method stub     

             }  


         public void beforeTextChanged( CharSequence s, int start, int before, int count) { 
             // TODO Auto-generated method stub       
         }  

         public void afterTextChanged( Editable s){
             {
                // TODO Auto-generated method stub  
                 arrayA.getFilter().filter(s); 

             }

that only filter the list not what i want is there only way i can do it ?


You should be able to achieve this by creating your own custom filter. You can get the Array adapter to use your custom filter by overriding the getFilter method

public Filter getFilter() {
        filter = new MyCustomFilter();

        return filter;
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜