Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

android - How do I remove popup text from listview filter?

I'm using a text filter on a ListView and I'd like to get rid of the popup view that shows what the filter text is. Is there any way to remove this view?

Some example code:

    ArrayList<String> buildingNames = new ArrayList<String>();
    ListView list = (ListView)findViewById(R.id.list);

    list.setAdapter(new ArrayAdapter<String>(this, R.layout.menu_item, buildingNames));
    list.setTextFilterEnabled(true);

    list.setFilterText("test_filter");

When I set the filter text, a really ugly view pops up at the bottom of the ListView that shows what the current filter text is:

ListView filter text popup

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I found the answer here: http://markmail.org/message/7uju6bmmaswag2lu:

By calling setTextFilterEnabled() you do request this popup. If you don't want it, disable text filtering. This is an interactive feature for the user. It is not meant to be used programatically. If you want to programatically filter your adapter, call getFilter() on your adapter directly (if your adapter supports filtering.)

Romain Guy

So rather than using setTextFilterEnabled you need to work with the filter directly like so:

CustomAdapter customAdapter = (customAdapter)myListView.getAdapter();
Filter filter = customAdapter .getFilter();
filter.filter("search string");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...