SearchView.OnCloseListener does not get invoked

后端 未结 9 621
慢半拍i
慢半拍i 2020-12-03 22:23

Im using an action bar and adding a searchView to it. I have implemented the searchView.onCLoseListener but this does not seem to be getting invoked. Any suggestions ?

9条回答
  •  抹茶落季
    2020-12-03 23:05

    To get notified when the 'x' icon is clicked, I added an on click listener to the SearchView 'x' button.

    Find the SearchView 'x' button by id and attach the OnClickListener:

    mSearchView.findViewById(R.id.search_close_btn)
        .setOnClickListener(this);
    

    The view search_close_btn is present in the SearchView layout provided by the Android framework.

提交回复
热议问题