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:com.imgtec.hobbyist.fragments.loginsignup.LogInFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    MenuItem appLogsItem = menu.getItem(0);
    appLogsItem.setVisible(loginError);
}

From source file:com.tenmiles.helpstack.fragments.ImageAttachmentDisplayFragment.java

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

    MenuItem downloadItem = menu.findItem(R.id.menu_download);
    if (image_url != null && image_url.startsWith("http")) {
        downloadItem.setVisible(true);
    } else {//from   www .  j  a  v  a2s.c om
        downloadItem.setVisible(false);
    }

}

From source file:ca.farrelltonsolar.classic.DayLogChart.java

private void setupSpinner(MenuItem item) {
    try {// w  ww .  j  av  a2s  . c  o  m
        item.setVisible(true);
        item.setActionView(R.layout.action_chart_select);
        View view = MenuItemCompat.getActionView(item);
        if (view instanceof Spinner) {
            Spinner spinner = (Spinner) view;
            String[] itemArray = getResources().getStringArray(R.array.day_log_chart_selection);
            ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this.getActivity(),
                    android.R.layout.simple_spinner_item, itemArray); //selected item will look like a spinner set from XML
            spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(spinnerArrayAdapter);
            spinner.setSelection(MonitorApplication.chargeControllers().getCurrentChargeController()
                    .getDayLogMenuSelection(), false);
            spinner.setOnItemSelectedListener(
                    new OnItemSelectedListenerWrapper(new AdapterView.OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                            chartView.clearSeries();
                            if (position < mSeries.size()) {
                                MonitorApplication.chargeControllers().getCurrentChargeController()
                                        .setDayLogMenuSelection(position);
                                chartView.addSeries(mSeries.get(position));
                            }
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> parent) {

                        }
                    }));
        }
    } catch (Exception ex) {
        Log.w(getClass().getName(), String.format("Day Log Chart failed to load setupSpinner %s ex: %s",
                Thread.currentThread().getName(), ex));
    }
}

From source file:hu.balazsbakai.sq.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main_actions, menu);
    final MenuItem searchItem = menu.findItem(R.id.action_search);
    searchItem.setVisible(false);
    // SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    return true;//  w ww  .  j ava  2  s  . c o  m
}

From source file:com.example.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);

    return super.onPrepareOptionsMenu(menu);
}

From source file:com.android.mail.ui.HelpFragment.java

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

    // if we have no play store URI, hide that menu item
    final MenuItem viewAppUrlMenuItem = menu.findItem(R.id.view_app_url);
    if (viewAppUrlMenuItem != null) {
        final String appUrl = getString(R.string.app_url);
        viewAppUrlMenuItem.setVisible(!TextUtils.isEmpty(appUrl));
    }//from  w w  w  .j a  v  a2  s.com

    // printing the content of the webview is only allowed if running on Kitkat or later
    final MenuItem printItem = menu.findItem(R.id.print_dialog);
    if (printItem != null) {
        printItem.setVisible(PrintHelper.systemSupportsPrint());
    }
}

From source file:com.jbirdvegas.mgerrit.GerritControllerActivity.java

private void hideChangelogOption(String gerrit) {
    MenuItem changelog = mMenu.findItem(R.id.menu_changelog);
    if (changelog != null) {
        changelog.setVisible(gerrit.contains("aokp"));
    }/*w w  w. j  ava  2  s  . co  m*/
}

From source file:htw.bui.openreskit.meter.SeriesActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem item = menu.findItem(R.id.scanBarcode);
    if (mScanningEnabled) {
        item.setVisible(true);
    } else {//from w  w w.j  a v  a 2  s.  c o  m
        item.setVisible(false);
    }
    return true;
}

From source file:dev.vision.shopping.center.Fragments.GourmetFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    //inflater.inflate(R.menu.main, menu);
    inflater.inflate(R.menu.offers, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    MenuItem expand = menu.findItem(R.id.expand);
    expand.setVisible(false);

    SearchView searchView = null;/*from   w  w w .  ja  v  a  2  s  .  c o m*/

    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    if (searchView == null)
        searchView = (SearchView) searchItem.getActionView();
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);

    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setOnQueryTextListener(this);

}

From source file:com.kasungunathilaka.sarigama.fragment.SearchFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    MenuItem searchItem = menu.findItem(R.id.action_search);
    MenuItem refreshItem = menu.findItem(R.id.action_refresh);
    searchItem.setVisible(false);
    refreshItem.setVisible(false);/*from ww w  . ja  va  2  s . c om*/

}