Is there any listener on Android SearchView to notify if SearchView is expanded and ready to take input?

前端 未结 4 1553
攒了一身酷
攒了一身酷 2021-02-13 11:10

I want to show some default suggestions in SearchView when User hasn\'t typed anything. I am setting my custom suggestion adapter manually using matrix cursor. I tried setting

4条回答
  •  滥情空心
    2021-02-13 11:52

    the questioner wants to know how to know when the searchview is expanded. just do this with your searchview (assuming its standalone but you can get a reference to it from menu item if needed):

    searchView.setOnSearchClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            //search is expanded
                        }
                    });
    

    here is for closed situation:

    searchView.setOnCloseListener(new SearchView.OnCloseListener() {
                        @Override
                        public boolean onClose() {
    // searchview closed
                            return false;
                        }
                    });
    

提交回复
热议问题