I\'m developing an app for Android 3.2 and greater with android-support-v4
. I need to implement OnActionExpandListener
for \"intercept\" when Searc
For MenuItemCompat.setOnActionExpandListener to work you should add "collapseActionView" added in the menu item - for example -
And in the onCreateOptionsMenu you can use it this way -
MenuItemCompat.setOnActionExpandListener(menu_search,
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
}
});