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:com.flowzr.activity.BlotterFragment.java

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

From source file:org.noorganization.instalist.view.fragment.ShoppingListOverviewFragment.java

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

From source file:com.flowzr.budget.holo.activity.BlotterFragment.java

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

    //super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.viktorrudometkin.burramys.fragment.EntriesListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear(); // This is needed to remove a bug on Android 4.0.3

    inflater.inflate(R.menu.entry_list, menu);

    MenuItem searchItem = menu.findItem(R.id.menu_search);
    final SearchView searchView = (SearchView) searchItem.getActionView();
    if (EntryColumns.isSearchUri(mCurrentUri)) {
        searchItem.expandActionView();/*from  ww  w.ja  va 2s .c om*/
        searchView.post(new Runnable() { // Without that, it just does not work
            @Override
            public void run() {
                searchView.setQuery(mCurrentUri.getLastPathSegment(), false);
                searchView.clearFocus();
            }
        });

    }

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (TextUtils.isEmpty(newText)) {
                setData(mOriginalUri, true);
            } else {
                setData(EntryColumns.SEARCH_URI(newText), true, true);
            }
            return false;
        }
    });
    searchView.setOnCloseListener(new SearchView.OnCloseListener() {
        @Override
        public boolean onClose() {
            setData(mOriginalUri, true);
            return false;
        }
    });

    if (EntryColumns.FAVORITES_CONTENT_URI.equals(mCurrentUri)) {
        menu.findItem(R.id.menu_refresh).setVisible(false);
    } else {
        menu.findItem(R.id.menu_share_starred).setVisible(false);
    }

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.supremainc.biostar2.monitor.MonitorFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuInflater inflater = mContext.getMenuInflater();
    switch (mSubMode) {
    default:/*from   w  w w  . ja  v a 2s . c  o m*/
    case MODE_NORMAL:
        initActionbar(getString(R.string.monitoring));
        inflater.inflate(R.menu.filter, menu);
        break;
    case MODE_FILTER:
        initActionbar(getString(R.string.filter));
        inflater.inflate(R.menu.filter_save, menu);
        break;
    }
    super.onPrepareOptionsMenu(menu);
}

From source file:co.carlosjimenez.android.currencyalerts.app.DetailActivityFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {

    if (data == null) {
        Log.d(LOG_TAG, "Detail Forex Loader Finished: No data returned");

        return;//from   w  w w.  j  a va  2s .c  o m
    }
    if (!data.moveToFirst()) {
        Log.d(LOG_TAG, "Detail Forex Loader Finished: No data returned");

        data.close();
        return;
    }

    long lDate = 0;
    String sDate = "";
    String sCurrency = "";
    int i = 0;
    double dRateAverage = 0;
    double dVal = 0;
    double dMinVal = 0;
    double dMaxVal = 0;

    data.moveToPosition(0);

    mCurrencyFromId = data.getString(COL_CURRENCY_FROM_ID);
    String currencyFromName = data.getString(COL_CURRENCY_FROM_NAME);
    String currencyFromSymbol = data.getString(COL_CURRENCY_FROM_SYMBOL);
    String countryFromName = data.getString(COL_COUNTRY_FROM_NAME);
    double currencyFromRate = ForexContract.RateEntry.getRateFromUri(mUri);

    mCurrencyToId = data.getString(COL_CURRENCY_TO_ID);
    String currencyToName = data.getString(COL_CURRENCY_TO_NAME);
    String currencyToSymbol = data.getString(COL_CURRENCY_TO_SYMBOL);
    String countryToName = data.getString(COL_COUNTRY_TO_NAME);
    double currencyToRate = ForexContract.RateEntry.getRateFromUri(mUri) * data.getDouble(COL_RATE_VAL);

    Glide.with(getActivity()).load(data.getString(COL_COUNTRY_FROM_FLAG)).error(R.drawable.globe).crossFade()
            .into(mIvFlagFrom);
    mIvFlagFrom.setContentDescription(Utility.formatCountryFlagName(mContext, countryFromName));

    Glide.with(getActivity()).load(data.getString(COL_COUNTRY_TO_FLAG)).error(R.drawable.globe).crossFade()
            .into(mIvFlagTo);
    mIvFlagFrom.setContentDescription(Utility.formatCountryFlagName(mContext, countryToName));

    mTvCurrencyFromDesc.setText(currencyFromName);
    mTvCurrencyFromDesc.setContentDescription(currencyFromName);

    mTvCurrencyFromRate
            .setText(Utility.formatCurrencyRate(getActivity(), currencyFromSymbol, currencyFromRate));
    mTvCurrencyFromRate.setContentDescription(String.valueOf(currencyFromRate) + " " + currencyFromName);

    mTvCurrencyToDesc.setText(currencyToName);
    mTvCurrencyToDesc.setContentDescription(currencyToName);

    mTvCurrencyToRate.setText(Utility.formatCurrencyRate(getActivity(), currencyToSymbol, currencyToRate));
    mTvCurrencyToRate.setContentDescription(String.valueOf(currencyToRate) + " " + currencyToName);

    Time dayTime = new Time();
    dayTime.setToNow();

    int julianDate = Time.getJulianDay(System.currentTimeMillis(), dayTime.gmtoff);

    dayTime = new Time();
    long lMinDate = dayTime.setJulianDay(julianDate - DEFAULT_DAYS_FOREX_AVERAGE);

    sDate = Utility.getDateString(getActivity(), data.getLong(COL_RATE_DATE));

    for (i = 0; i < data.getCount() && i < DEFAULT_DAYS_FOREX_AVERAGE; i++) {
        data.moveToPosition(i);

        lDate = data.getLong(COL_RATE_DATE);
        if (lDate < lMinDate) {
            break;
        }

        sCurrency = data.getString(COL_CURRENCY_TO_ID);
        sDate = Utility.getDateString(getActivity(), lDate);
        dVal = data.getDouble(COL_RATE_VAL);
        dRateAverage += dVal;

        if (i == 0) {
            dMinVal = dVal;
            dMaxVal = dVal;
        } else {
            dMinVal = dMinVal < dVal ? dMinVal : dVal;
            dMaxVal = dMaxVal > dVal ? dMaxVal : dVal;
        }
    }
    dRateAverage = dRateAverage / i;

    if (data.getCount() > 1)
        mTvPeriod.setText(data.getCount() + " days");
    else
        mTvPeriod.setText(data.getCount() + " day");
    mTvMaxRate.setContentDescription(mTvPeriod.getText());

    mTvMaxRate.setText(
            Utility.formatCurrencyRate(getActivity(), data.getString(COL_CURRENCY_TO_SYMBOL), dMaxVal));
    mTvMaxRate.setContentDescription(mTvMaxRate.getText());

    mTvMinRate.setText(
            Utility.formatCurrencyRate(getActivity(), data.getString(COL_CURRENCY_TO_SYMBOL), dMinVal));
    mTvMinRate.setContentDescription(mTvMinRate.getText());

    mTvAverageRate.setText(
            Utility.formatCurrencyRate(getActivity(), data.getString(COL_CURRENCY_TO_SYMBOL), dRateAverage));
    mTvAverageRate.setContentDescription(mTvAverageRate.getText());

    // String text to share if user clicks on share menu icon
    mDisplayedRate = String.format("%s - %s %s = %s %s", sDate, currencyFromRate, mCurrencyFromId,
            currencyToRate, mCurrencyToId);
    mDisplayedCurrencyIds = mCurrencyFromId + "-" + mCurrencyToId;
    mDisplayedCurrencyNames = currencyToName;

    mContext.supportStartPostponedEnterTransition();

    if (null != mToolbar) {
        Menu menu = mToolbar.getMenu();
        if (null != menu)
            menu.clear();
        mToolbar.inflateMenu(R.menu.detailfragment);
        finishCreatingMenu(mToolbar.getMenu());
    }
}

From source file:eu.trentorise.smartcampus.trentinofamiglia.fragments.event.EventsListingFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    getActivity().getMenuInflater().inflate(R.menu.list_menu, menu);

    if (category == null) {
        category = (getArguments() != null) ? getArguments().getString(SearchFragment.ARG_CATEGORY) : null;
    }//from w  ww . j  av a  2 s.co m

    super.onPrepareOptionsMenu(menu);
}

From source file:com.odoo.addons.notes.Notes.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.menu_notes, menu);
    setHasSearchView(this, menu, R.id.menu_note_search);
}

From source file:com.mastercard.masterpasswallet.fragments.MainCardFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_cards, menu);
    menu.findItem(R.id.show_shipping_addresses).setVisible(false);

}

From source file:pw.dedominic.airc.App.java

public void recreateDrawerItems() {
    Menu menu = navView.getMenu();
    menu.clear();
    SubMenu smenu = menu.addSubMenu("Servers");
    for (Server server : dao) {
        if (server.equals(selectedServer))
            smenu.add(server.getTitle()).setIcon(R.drawable.green_circle);
        else/*  w  ww .j a  v  a  2  s. c  o  m*/
            smenu.add(server.getTitle());
    }
    smenu = menu.addSubMenu("Actions");
    String[] actions = getResources().getStringArray(R.array.nav_items);
    if (actions.length != 5)
        throw new RuntimeException("LOLWUT?");
    smenu.add(actions[0]).setIcon(android.R.drawable.ic_input_add);
    smenu.add(actions[1]).setIcon(android.R.drawable.ic_menu_edit);
    smenu.add(actions[2]).setIcon(android.R.drawable.ic_menu_delete);
    smenu.add(actions[3]).setIcon(android.R.drawable.ic_menu_preferences);
    smenu.add(actions[4]);

}