Example usage for android.view MenuItem setVisible

List of usage examples for android.view MenuItem setVisible

Introduction

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

Prototype

public MenuItem setVisible(boolean visible);

Source Link

Document

Sets the visibility of the menu item.

Usage

From source file:net.sourceforge.lifeograph.ActivityChapterTag.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    boolean flagPseudoElement = (mElement == Diary.diary.m_orphans);
    boolean flagWritable = !Diary.diary.is_read_only();
    DiaryElement.Type type = mElement.get_type();

    MenuItem item = menu.findItem(R.id.change_todo_status);
    item.setVisible(type != DiaryElement.Type.UNTAGGED && !flagPseudoElement && flagWritable);

    //  TODO WILL BE IMPLEMENTED IN 0.4
    //        item = menu.findItem( R.id.change_sort_type );
    //        item.setVisible( mParentElem != null );

    item = menu.findItem(R.id.add_entry);
    item.setVisible((type == DiaryElement.Type.TOPIC || type == DiaryElement.Type.GROUP) && flagWritable);

    item = menu.findItem(R.id.dismiss);/*from www  .j av  a  2s  .co m*/
    item.setVisible(!flagPseudoElement && flagWritable);

    item = menu.findItem(R.id.rename);
    item.setVisible(!flagPseudoElement && flagWritable);

    return true;
}

From source file:org.enbyted.android.zseinfo.view.activity.MainActivity.java

@Override
public void notifyUiChanged() {
    if (menu != null) {
        BaseSection currentSection = pagerAdapter
                .getSection(getSupportActionBar().getSelectedTab().getPosition());
        MenuItem menuItem = menu.findItem(R.id.action_refresh);
        if (menuItem != null)
            menuItem.setVisible(currentSection.isRefreshActive());
        getSupportActionBar().setDisplayHomeAsUpEnabled(currentSection.isBackActive());
    }//w  ww.  j  a  v  a  2  s.com
}

From source file:com.vose.fragment.action.RulesFragment.java

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

    if (componentSource == ComponentSource.MainTabHostActivity) {

        ((MainTabHostActivity) getActivity()).hideActionBarMenuItems(menu);

        MenuItem overFlowMenu = menu.findItem(R.id.menu_overflow);
        overFlowMenu.setVisible(false);
    }/*from  w  ww  . ja  v  a 2  s  . c o m*/

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:io.syng.fragment.profile.ProfileDialogFragment.java

private void invalidateToolbarMenu() {
    MenuItem exp = mToolbar.getMenu().findItem(R.id.action_key_export);
    MenuItem imp = mToolbar.getMenu().findItem(R.id.action_key_import);
    boolean showExport = mViewPager.getCurrentItem() == ProfileViewPagerAdapter.KEYS_POSITION;
    exp.setVisible(showExport);
    imp.setVisible(showExport);//  w w  w  . j  a v a  2 s. com
}

From source file:com.dustinmreed.openwifi.DetailFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detailfragment, menu);

    // Retrieve the share menu item
    MenuItem menuItem = menu.findItem(R.id.action_share);
    if (mWiFiLocation == null) {
        menuItem.setVisible(false);
    }//from   w w w . j  a  v a  2 s. c o  m
    // Get the provider and hold onto it to set/change the share intent.
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    // If onLoadFinished happens before this, we can go ahead and set the share intent now.
    if (mWiFiLocation != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
    }
}

From source file:com.sintef_energy.ubisolar.fragments.UsageFragment.java

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

    if (!Session.getActiveSession().isOpened()) {
        MenuItem item = menu.findItem(R.id.share_usage);
        item.setVisible(false);
    }//w w w  . j av  a 2s.c  o  m
}

From source file:com.justplay1.shoppist.features.lists.MainActivity.java

@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    super.onPrepareActionMode(mode, menu);
    MenuItem edit = menu.findItem(R.id.action_edit);
    if (edit != null) {
        edit.setVisible(listFragment.isEditButtonEnable());
    }//from  w w w.  jav a 2s .c o m
    MenuItem checkAll = menu.findItem(R.id.menu_check_all);
    checkAll.setEnabled(listFragment.isCheckAllButtonEnable());
    return true;
}

From source file:com.money.manager.ex.reports.PayeeReportFragment.java

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

    // pie chart/*from   w  w  w  .  j a  v  a 2 s  . c  o  m*/
    MenuItem itemChart = menu.findItem(R.id.menu_chart);
    if (itemChart != null) {
        itemChart.setVisible(!(((PayeesReportActivity) getActivity()).mIsDualPanel));
        UIHelper uiHelper = new UIHelper(getActivity());
        itemChart.setIcon(uiHelper.resolveAttribute(R.attr.ic_action_pie_chart));
    }
}

From source file:butter.droid.activities.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.activity_overview, menu);

    MenuItem playerTestMenuItem = menu.findItem(R.id.action_playertests);
    playerTestMenuItem.setVisible(Constants.DEBUG_ENABLED);

    return true;//from   ww w  .j a  va  2  s.c  o  m
}

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.EditFragment.java

/**
 * Creates and initialzes the menu of the fragment. Called only by Android.
 * /*from   w w w. ja v a  2s .c o m*/
 * @param menu The Menu object for the fragment.
 * @param inflater The inflater for the menu.
 */
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    MenuItem item = menu.findItem(R.id.action_settings);
    item.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}