ActionBar搜索视图,如何处理左箭头点击?

ActionBar search view, how to handle left arrow click?

图片如下:

如何处理左箭头单击? 我通过意图进行了搜索,没关系:

@Override
protected void onNewIntent(Intent intent) {
    handleIntent(intent);
}

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        mFilter = intent.getStringExtra(SearchManager.QUERY);
        ...search query
    }
}

和我的关闭按钮代码:

ImageView closeButton = (ImageView) searchView.findViewById(R.id.search_close_btn);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
...
}

如何处理左箭头单击?

SearchView 小部件中有 OnCloseListener

searchView.setOnCloseListener(new SearchView.OnCloseListener() {
    ...
});
// When using the support library, the setOnActionExpandListener() method is
// static and accepts the MenuItem object as an argument
MenuItemCompat.setOnActionExpandListener(menuItem, new OnActionExpandListener() {
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
    // Do something when collapsed
    return true;  // Return true to collapse action view
}

@Override
public boolean onMenuItemActionExpand(MenuItem item) {
    // Do something when expanded
    return true;  // Return true to expand action view
}
});

来自这里: