Example usage for android.view MenuInflater MenuInflater

List of usage examples for android.view MenuInflater MenuInflater

Introduction

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

Prototype

public MenuInflater(Context context) 

Source Link

Document

Constructs a menu inflater.

Usage

From source file:org.mozilla.gecko.home.RemoteTabsBaseFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
    if (!(menuInfo instanceof RemoteTabsClientContextMenuInfo)) {
        // Long pressed item was not a RemoteTabsGroup item. Superclass
        // can handle this.
        super.onCreateContextMenu(menu, view, menuInfo);
        return;/*from   w w  w .  j a v  a 2s .c  o  m*/
    }

    // Long pressed item was a remote client; provide the appropriate menu.
    final MenuInflater inflater = new MenuInflater(view.getContext());
    inflater.inflate(R.menu.home_remote_tabs_client_contextmenu, menu);

    final RemoteTabsClientContextMenuInfo info = (RemoteTabsClientContextMenuInfo) menuInfo;
    menu.setHeaderTitle(info.client.name);

    // Hide unused menu items.
    final boolean isHidden = sState.isClientHidden(info.client.guid);
    final MenuItem item = menu
            .findItem(isHidden ? R.id.home_remote_tabs_hide_client : R.id.home_remote_tabs_show_client);
    item.setVisible(false);
}

From source file:com.koushikdutta.superuser.PolicyFragmentInternal.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuInflater mi = new MenuInflater(getActivity());
    mi.inflate(R.menu.main, menu);/*  www.  j  av  a  2  s .  c  om*/
    MenuItem log = menu.findItem(R.id.logs);
    log.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            showAllLogs();
            return true;
        }
    });

    MenuItem settings = menu.findItem(R.id.settings);
    settings.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        void openSettingsNative(final MenuItem item) {
            setContent(createSettingsNativeFragment(), true, getString(R.string.settings));
        }

        @Override
        public boolean onMenuItemClick(final MenuItem item) {
            if (getActivity() instanceof FragmentActivity) {
                setContent(new SettingsFragment(), true, getString(R.string.settings));
            } else {
                openSettingsNative(item);
            }
            return true;
        }
    });
}

From source file:com.gsma.rcs.ri.sharing.geoloc.InitiateGeolocSharing.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = new MenuInflater(getApplicationContext());
    inflater.inflate(R.menu.menu_geoloc_sharing, menu);
    return true;/*w w  w.  j a  v  a  2 s  . c o  m*/
}

From source file:org.sigimera.app.android.CrisesListFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    menu.setHeaderTitle("Options");
    menu.setHeaderIcon(R.drawable.sigimera_logo);
    MenuInflater inflater = new MenuInflater(getActivity());
    inflater.inflate(R.menu.list_menu, menu);
}

From source file:com.gsma.rcs.ri.sharing.image.InitiateImageSharing.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = new MenuInflater(getApplicationContext());
    inflater.inflate(R.menu.menu_image_sharing, menu);
    return true;//from   w  w  w . ja va 2 s  . co  m
}

From source file:com.github.sryze.wirebug.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = new MenuInflater(this);
    menuInflater.inflate(R.menu.menu_main, menu);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.almarsoft.GroundhogReader.ComposeActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    new MenuInflater(getApplication()).inflate(R.menu.composemenu, menu);
    return (super.onCreateOptionsMenu(menu));

}

From source file:com.workingagenda.democracydroid.Adapters.ViewHolders.EpisodeViewHolder.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    MenuInflater inflater = new MenuInflater(itemView.getContext());
    menu.setHeaderTitle("Democracy Now!");
    inflater.inflate(R.menu.context_menu, menu);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(itemView.getContext());
    int DEFAULT_STREAM = Integer.parseInt(preferences.getString("stream_preference", "0")); // 0=video
    int DEFAULT_OPEN = Integer.parseInt(preferences.getString("open_preference", "0")); // 0 = within this app

    if (DEFAULT_STREAM == 0)
        menu.getItem(2).setTitle("Stream Audio");
    else/*from  w ww  . j av  a2 s .  co m*/
        menu.getItem(2).setTitle("Stream Video");

    if (DEFAULT_OPEN == 0)
        menu.getItem(3).setTitle("Stream in Another App");
    else
        menu.getItem(3).setTitle("Stream in This App");
    for (int i = 0; i < menu.size(); i++) {
        menu.getItem(i).setOnMenuItemClickListener(this);
    }
}

From source file:com.fn.reunion.app.ui.base.AppBaseActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    new MenuInflater(this).inflate(R.menu.app_main_menu, menu);
    return (super.onCreateOptionsMenu(menu));
}

From source file:com.ushahidi.android.app.ui.phone.ListMapActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    new MenuInflater(this).inflate(R.menu.list_map_context, menu);
}