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:eu.funceptionapps.convertitall.ui.ConverterInterface.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    final MenuItem item = menu.findItem(R.id.menu_item_update_currencies);
    if (item != null)
        item.setVisible(isCurrency);
    return true;/*from  ww w . j  av  a2 s . c om*/
}

From source file:htw.bui.openreskit.discard.InspectionActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    Inspection insp = mRepository.getInspectionById(mInspectionId);
    if (insp != null && !insp.isFinished()) {
        MenuItem startItem = menu.findItem(R.id.startInspection);
        MenuItem stopItem = menu.findItem(R.id.finishInspection);
        if (mInspectionId != 0) {
            if (mInspectionRunning) {
                //show stop button
                startItem.setVisible(false);
                stopItem.setVisible(true);
            } else {
                //show start button
                startItem.setVisible(true);
                stopItem.setVisible(false);
            }//from w w w.j  av  a  2 s . c om
        }
    }
    return true;
}

From source file:com.pacoapp.paco.ui.FindMyExperimentsActivity.java

@SuppressLint("NewApi")
@Override//from w  ww . ja va 2  s  . c  o m
public boolean onCreateOptionsMenu(Menu menu) {
    int pos = 1;
    if (true || !mNavigationDrawerFragment.isDrawerOpen()) {
        getMenuInflater().inflate(R.menu.main, menu);
        // restoreActionBar();
        // TODO hide find experiments (this is that item)
        // TODO make refresh be an always action
        MenuItem findExperiments = menu.getItem(0);
        findExperiments.setVisible(false);
        MenuItem refreshExperiments = menu.getItem(1);
        refreshExperiments.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        return true;
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.kaliturin.blacklist.fragments.ContactsFragment.java

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

    // tune menu options
    MenuItem itemSearch = menu.findItem(R.id.action_search);
    Utils.setMenuIconTint(getContext(), itemSearch, R.attr.colorAccent);
    itemSearch.setVisible(true);
    MenuItem itemAdd = menu.findItem(R.id.action_add);
    Utils.setMenuIconTint(getContext(), itemAdd, R.attr.colorAccent);
    itemAdd.setVisible(true);//ww  w .  j a  v a  2  s . co  m

    // get the view from search menu item
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(itemSearch);
    searchView.setQueryHint(getString(R.string.Search_action));
    // set on text change listener
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            reloadItems(newText);
            return true;
        }
    });

    // on search cancelling
    // SearchView.OnCloseListener is not calling so use other way...
    MenuItemCompat.setOnActionExpandListener(itemSearch, new MenuItemCompat.OnActionExpandListener() {
        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            reloadItems(null);
            return true;
        }
    });

    // item's 'add contact' on click listener
    itemAdd.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            // show menu dialog
            showAddContactsMenuDialog();

            return true;
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.apps8os.motivator.ui.MoodHistoryActivity.java

/**
 * Loading the action bar menu/*from   w w w  . ja va  2  s .  com*/
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.mood_history, menu);
    mMenu = menu;
    MenuItem selectAttribute = mMenu.findItem(R.id.mood_history_select_attribute);
    if (mRes.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        selectAttribute.setVisible(false);
    } else {
        selectAttribute.setVisible(true);
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.wewow.BaseActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.toolbar, menu);
    MenuItem menuItem = menu.findItem(R.id.search);
    menuItem.setVisible(false);
    return true;/*  ww w.  j  a  v a  2  s. c om*/
}

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_report_income_vs_expenses, menu);
    // fix menu char
    MenuItem itemChart = menu.findItem(R.id.menu_chart);
    if (itemChart != null) {
        Activity activity = getActivity();
        if (activity instanceof IncomeVsExpensesActivity) {
            itemChart.setVisible(!((IncomeVsExpensesActivity) activity).mIsDualPanel);
        }/*  w ww  . j  a v  a2  s  .  co  m*/
    }
}

From source file:com.retroteam.studio.retrostudio.MeasureEditor.java

/**
 * Toggle the ability to draw notes.//from w  w w  .j  a v a 2s .co  m
 * @param view
 */
public void togglePencilTool(View view) {

    com.getbase.floatingactionbutton.FloatingActionButton ptool = (com.getbase.floatingactionbutton.FloatingActionButton) view;

    if (pencil) {
        pencil = false;
        ptool.setVisibility(View.VISIBLE);
    } else {
        pencil = true;
        ptool.setVisibility(View.INVISIBLE);
        MenuItem cross = actionMenu.findItem(R.id.action_penciloff);
        cross.setVisible(true);

    }
}

From source file:com.nextgis.mobile.fragment.AttributesFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        if (item.getItemId() == R.id.menu_about || item.getItemId() == R.id.menu_settings) {
            continue;
        }//from  w ww  . j a va 2 s  .  c  o  m
        item.setVisible(false);
    }
    super.onPrepareOptionsMenu(menu);
}

From source file:com.kanedias.vanilla.lyrics.LyricsShowActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    for (int i = 0; i < menu.size(); i++) {
        MenuItem item = menu.getItem(i);
        switch (item.getItemId()) {
        case R.id.reload_option:
            // show only when loading is complete
            item.setVisible(mSwitcher.getDisplayedChild() == 1);
            continue;
        default://from w ww.j  av  a  2  s  .c  om
            break;
        }
    }
    return super.onPrepareOptionsMenu(menu);
}