1

Here is the picture: enter image description here

How can I handle left arrow click? I did my search through intent, that is OK:

@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
    }
}

and my close button code:

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

How can I handle left arrow click?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Foenix
  • 376
  • 4
  • 18

2 Answers2

1
// 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
}
});

This is from here:https://stackoverflow.com/a/18186164/4200187

Community
  • 1
  • 1
Foenix
  • 376
  • 4
  • 18
0

There is OnCloseListener in SearchView widget.

searchView.setOnCloseListener(new SearchView.OnCloseListener() {
    ...
});
Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98