How to check if my listview adapter is filterd by my editext text or not?

前端 未结 1 1618
别那么骄傲
别那么骄傲 2021-01-17 04:24

I have a editext for search in a list view. I want to check if listview adapter is filtered by any text or not. Here is my code:

    Button search=(Button)fi         


        
相关标签:
1条回答
  • 2021-01-17 05:10

    Filter has a overridden method with Filter.FilterListener which you can use .

    search.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                adapter.getFilter().filter(inputSearch.getText().toString(),new Filter.FilterListener(){
                    @Override
                    public void onFilterComplete(int count) {
                        if (count == 0){
                            // List empty
                        } else {
                            // List has data
                        }
                    }
                });
            }});
    
    0 讨论(0)
提交回复
热议问题