Example usage for android.view Menu clear

List of usage examples for android.view Menu clear

Introduction

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

Prototype

public void clear();

Source Link

Document

Remove all existing items from the menu, leaving it empty as if it had just been created.

Usage

From source file:it.jaschke.alexandria.activity.ListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (null != menu)
        menu.clear();
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;/*from w w w  .  j  a  v a  2  s  .c o  m*/
}

From source file:nz.ac.auckland.lablet.ExperimentAnalysisFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();

    setupStandardMenu(menu, inflater);
}

From source file:io.apptik.multiview.ScrollersFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.scrollers, menu);

}

From source file:com.cranberrygame.phonegap.plugin.OptionsMenu.java

@Override
public Object onMessage(String id, Object data) {
    //https://github.com/dpogue/cordova-plugin-cambie/blob/master/src/android/Cambie.java
    //http://stackoverflow.com/questions/22403984/get-oncreateoptionsmenu-in-cordova-plugin
    //https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java#L140
    if (id.equals("onCreateOptionsMenu") || id.equals("onPrepareOptionsMenu")) {
        Menu menu = (Menu) data;

        if (this.menus != null) {
            menu.clear();

            String[] _menus = this.menus.split(",");
            for (int i = 0; i < _menus.length; i++) {
                menu.add(0, i, 0, _menus[i]);
            }//w w  w  .j a  va  2s  . c o  m
        }
    } else if (id.equals("onOptionsItemSelected")) {
        MenuItem item = (MenuItem) data;

        webView.loadUrl(String.format("javascript:cordova.fireDocumentEvent('onMenuSelected', {'menu': '%s'});",
                item.getTitle()));
    }

    return null;
}

From source file:com.mifos.mifosxdroid.online.LoanRepaymentScheduleFragment.java

/**
 * Prepare the Screen's standard options menu to be displayed.  This is
 * called right before the menu is shown, every time it is shown.  You can
 * use this method to efficiently enable/disable items or otherwise
 * dynamically modify the contents.  See
 * {@link android.app.Activity#onPrepareOptionsMenu(android.view.Menu) Activity.onPrepareOptionsMenu}
 * for more information./*from   w  w w . j  av a 2s  .  c  om*/
 *
 * @param menu The options menu as last shown or first initialized by
 *             onCreateOptionsMenu().
 * @see #setHasOptionsMenu
 * @see #onCreateOptionsMenu
 */
@Override
public void onPrepareOptionsMenu(Menu menu) {

    menu.clear();

    super.onPrepareOptionsMenu(menu);
}

From source file:com.social.solution.activity.TrendingTweetsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.clear();
    getMenuInflater().inflate(R.menu.mymenutrend, menu);
    System.out.println("pranjal menu has visible items " + menu.hasVisibleItems());
    return true;/*from   w w w .j a v  a2 s  . c o m*/
}

From source file:com.cranberrygame.cordova.plugin.optionsmenu.OptionsMenu.java

@Override
public Object onMessage(String id, Object data) {
    //https://github.com/dpogue/cordova-plugin-cambie/blob/master/src/android/Cambie.java
    //http://stackoverflow.com/questions/22403984/get-oncreateoptionsmenu-in-cordova-plugin
    //https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java#L140
    if (id.equals("onCreateOptionsMenu") || id.equals("onPrepareOptionsMenu")) {
        Menu menu = (Menu) data;

        if (this.menus != null) {
            menu.clear();

            String[] _menus = this.menus.split(",");
            for (int i = 0; i < _menus.length; i++) {
                menu.add(0, i, 0, _menus[i]);
            }//ww w  .  ja v  a2 s.  c  o  m
        }
    } else if (id.equals("onOptionsItemSelected")) {
        MenuItem item = (MenuItem) data;

        //webView.loadUrl(String.format("javascript:cordova.fireDocumentEvent('onMenuSelected', {'menu': '%s'});", item.getTitle()));

        Log.d(LOG_TAG, "onOptionsItemSelected: " + item.getTitle());

        JSONObject result = new JSONObject();
        try {
            result.put("event", "onMenuSelected");
            result.put("message", item.getTitle());
        } catch (JSONException ex) {
        }
        //PluginResult pr = new PluginResult(PluginResult.Status.OK, "onMenuSelected");
        PluginResult pr = new PluginResult(PluginResult.Status.OK, result);
        pr.setKeepCallback(true);
        callbackContextKeepCallback.sendPluginResult(pr);
        //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
        //pr.setKeepCallback(true);
        //callbackContextKeepCallback.sendPluginResult(pr);            
    }

    return null;
}

From source file:org.apps8os.logger.android.fragment.LoggerHistoryFragment2.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    if (menu != null) {
        menu.clear();
    }
}

From source file:org.alfresco.mobile.android.application.fragments.activitystream.ActivityFeedFragment.java

public void getMenu(Menu menu) {
    menu.clear();
    MenuFragmentHelper.getMenu(getActivity(), menu);
}

From source file:org.kaaproject.kaa.demo.photoframe.fragment.AlbumsFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();

    getActivity().getMenuInflater().inflate(R.menu.menu_photo_frame, menu);
    menu.findItem(R.id.item_stop).setVisible(mIsPlaying);
}