Example usage for android.view MenuItem isActionViewExpanded

List of usage examples for android.view MenuItem isActionViewExpanded

Introduction

In this page you can find the example usage for android.view MenuItem isActionViewExpanded.

Prototype

public boolean isActionViewExpanded();

Source Link

Document

Returns true if this menu item's action view has been expanded.

Usage

From source file:net.ustyugov.jtalk.activity.XMLConsole.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    String acc = (String) mPages.get(mPager.getCurrentItem()).getTag();
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();//www.ja va 2  s. c o  m
        break;
    case R.id.search:
        if (!item.isActionViewExpanded()) {
            item.expandActionView();
        }
        break;
    case R.id.clear:
        XmlListener listener = JTalkService.getInstance().getXmlListener(acc);
        if (listener != null)
            listener.clear();
        updateList();
        break;
    default:
        return false;
    }
    return true;
}

From source file:app.cloud9.com.cloud9.NoticeBoard.java

@Override
public boolean onSearchRequested() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        MenuItem mi = mMenu.findItem(R.id.search_notice);
        if (mi.isActionViewExpanded()) {
            mi.collapseActionView();/*from   ww  w  .j  a  va2 s .c  o m*/
        } else {
            mi.expandActionView();
        }
    } else {
        //onOptionsItemSelected(mMenu.findItem(R.id.search));
    }
    return super.onSearchRequested();
}