SearchView's OnCloseListener doesn't work

前端 未结 18 2563
有刺的猬
有刺的猬 2020-11-27 02:44

I\'m trying to add support for the SearchView in the Android 3.0+ ActionBar, but I can\'t get the OnCloseListener to work.

Here\'s my code:

18条回答
  •  误落风尘
    2020-11-27 03:22

    I also meet this problem, and I have no choice but give up "oncloselistener". Instead, you can get your menuItem, then setOnActionExpandListener. Then override unimplents methods.

    @Override
    public boolean onMenuItemActionExpand(MenuItem item) {
        // TODO Auto-generated method stub
        Log.d("*******","onMenuItemActionExpand");
        return true;
    }
    
    @Override
    public boolean onMenuItemActionCollapse(MenuItem item) {
        //do what you want to when close the sesarchview
        //remember to return true;
        Log.d("*******","onMenuItemActionCollapse");
        return true;
    }
    

提交回复
热议问题