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:am.project.x.business.main.MainActivity.java

@Override
protected void initializeActivity(@Nullable Bundle savedInstanceState) {
    ViewUtils.setLayoutFullscreen(getWindow().getDecorView(), false);

    final Toolbar toolbar = findViewById(R.id.main_toolbar);
    mVDrawer = findViewById(R.id.main_drawer);
    mVContent = findViewById(R.id.main_lyt_content);
    final NavigationView navigation = findViewById(R.id.main_navigation);

    setSupportActionBar(toolbar);//from  w w  w.java 2  s  . com
    final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mVDrawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    toggle.setToolbarNavigationClickListener(this);
    mVDrawer.addDrawerListener(toggle);
    toggle.syncState();
    navigation.setNavigationItemSelectedListener(this);
    final String tag;
    final boolean debug = BuildConfig.DEBUG;
    if (savedInstanceState == null) {
        tag = TAG_WIDGETS;
        final MenuItem item = navigation.getMenu().findItem(R.id.main_nav_widgets);
        item.setChecked(true);
        setTitle(item.getTitle());
        if (debug)
            DevelopingActivity.start(this);
    } else {
        tag = savedInstanceState.getString(EXTRA_FRAGMENT, TAG_WIDGETS);
        MenuItem item;
        switch (tag) {
        default:
        case TAG_WIDGETS:
            item = navigation.getMenu().findItem(R.id.main_nav_widgets);
            break;
        case TAG_DRAWABLES:
            item = navigation.getMenu().findItem(R.id.main_nav_drawables);
            break;
        case TAG_OTHERS:
            item = navigation.getMenu().findItem(R.id.main_nav_others);
            break;
        case TAG_DEVELOP:
            item = navigation.getMenu().findItem(R.id.main_nav_develop);
            break;
        }
        item.setChecked(true);
        setTitle(item.getTitle());
    }
    final MenuItem develop = navigation.getMenu().findItem(R.id.main_nav_develop);
    develop.setVisible(debug);
    setFragment(tag);
}

From source file:com.smartx.bill.mepad.mestore.uimgloader.AbsListViewBaseActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem pauseOnScrollItem = menu.findItem(R.id.item_pause_on_scroll);
    pauseOnScrollItem.setVisible(true);
    pauseOnScrollItem.setChecked(pauseOnScroll);

    MenuItem pauseOnFlingItem = menu.findItem(R.id.item_pause_on_fling);
    pauseOnFlingItem.setVisible(true);//from ww  w.j  a va  2  s  .c  o m
    pauseOnFlingItem.setChecked(pauseOnFling);
    return true;
}

From source file:ca.rmen.android.palidamuerte.app.poem.detail.PoemDetailActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    Log.v(TAG, "onPrepareOptionsMenu");
    super.onPrepareOptionsMenu(menu);
    MenuItem prev = menu.findItem(R.id.action_prev);
    MenuItem next = menu.findItem(R.id.action_next);
    prev.setVisible(true);
    next.setVisible(true);//ww w .ja va 2s .c  om
    if (mPoemPagerAdapter != null) {
        prev.setEnabled(mViewPager.getCurrentItem() > 0);
        next.setEnabled(mViewPager.getCurrentItem() < mPoemPagerAdapter.getCount() - 1);
    }
    final View view = menu.findItem(R.id.action_share).getActionView();
    ActionBar.hackSetMaxHeight(view, getActionBar().getHeight());
    return true;
}

From source file:com.rmaginot.android.bluetoothchat.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
    //logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator);
    //logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log);
    logToggle.setVisible(false);
    return super.onPrepareOptionsMenu(menu);
}

From source file:de.aw.monma.wertpapier.action.FragmentWertpapierUmsatz.java

/**
 * Blendet in Abhaengigkeit der {@link Action} und des Umsatzes das deleteItem bzw. das
 * CommissionItem aus.//from  ww w.  j  a  v  a  2 s.c  o m
 */
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.fragment_wertpapierumsatz, menu);
    MenuItem item = menu.findItem(R.id.menu_item_delete_Buchung);
    item.setVisible(mUmsatz.isDeleteable());
}

From source file:com.linroid.pushapp.ui.bind.BindActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.bind, menu);
    MenuItem item = menu.findItem(R.id.progressbar);
    MenuItemCompat.setActionView(item, R.layout.progressbar);
    item.setVisible(showProgress);
    return true;/*from   w  w w.  j  a  va 2  s  .  c o m*/
}

From source file:com.cypress.cysmart.CommonFragments.ProfileControlFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();/*from   www.  j  a v  a 2  s .  co m*/
    inflater.inflate(R.menu.global, menu);
    MenuItem graph = menu.findItem(R.id.graph);
    MenuItem log = menu.findItem(R.id.log);
    MenuItem search = menu.findItem(R.id.search);
    MenuItem clearcache = menu.findItem(R.id.clearcache);
    search.setVisible(false);
    graph.setVisible(false);
    log.setVisible(true);
    clearcache.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.numenta.taurus.instance.InstanceListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean res = super.onCreateOptionsMenu(menu);

    // Get the SearchView and set the searchable configuration
    MenuItem searchItem = menu.findItem(R.id.menu_search);
    searchItem.setVisible(true);
    final SearchView searchView = (SearchView) searchItem.getActionView();
    if (searchView != null) {
        configureSearchView(searchView);
    }//from   w w  w. j av  a 2s .c o  m

    MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() {
        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            ((AnomalyListAdapter) _listFragment.getListAdapter()).sort();
            if (_favorites.getCheckedRadioButtonId() == R.id.filter_none) {
                _listFragment.clearFilter();
            } else {
                _listFragment.filterFavorites();
            }
            _listFragment.showHeaders(true);
            return true;
        }

        public boolean onMenuItemActionExpand(MenuItem item) {
            ((AnomalyListAdapter) _listFragment.getListAdapter())
                    .sort(DataUtils.<InstanceAnomalyChartData>getSortByNameComparator());
            _listFragment.clearFilter();
            _listFragment.showHeaders(false);
            return true;
        }
    });

    return res;
}

From source file:com.cypress.cysmart.BLEServiceFragments.BatteryInformationService.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();//  w  w  w  .  ja va 2  s .  c  om
    inflater.inflate(R.menu.global, menu);
    MenuItem graph = menu.findItem(R.id.graph);
    MenuItem log = menu.findItem(R.id.log);
    MenuItem search = menu.findItem(R.id.search);
    search.setVisible(false);
    graph.setVisible(false);
    log.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.darizotas.metadatastrip.FileDetailFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    MenuItem item = menu.findItem(R.id.location);
    Boolean enabled = getUriGeoLocation() != null;
    item.setVisible(enabled);
    item.setEnabled(enabled);//from w ww  .j a v a  2s .c  om
}