开发者

listView Search in android?

I create listView by use the following code.If i use lv.setTextFilterEnabled(true); i get the list View filter.If i set the filter text its not display the filtered listView.How to set the filter text;

 lv=new ListView(this);        
    lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_checked, ite开发者_如何学JAVAms)); 
    //lv.setTextFilterEnabled(true);
    lv.setFilterText("a");

Note :

I have the TextViews A to Z . When i touch letter 'a' i wish to list the elements starts with 'a' so that i need to set the list filter at run time.


Try this code:

adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_checked, items);        
lv.setListAdapter(adapter);        
lv.setTextFilterEnabled(true);
adapter.getFilter().filter("a");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜