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.daiki.arduino.mcheck.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:br.liveo.ndrawer.FragmentMain.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // TODO Auto-generated method stub
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu, menu);

    //Select search item
    final MenuItem menuItem = menu.findItem(R.id.menu_search);
    menuItem.setVisible(true);

    SearchView searchView = (SearchView) menuItem.getActionView();
    searchView.setQueryHint(this.getString(R.string.search));

    ((EditText) searchView.findViewById(R.id.search_src_text))
            .setHintTextColor(getResources().getColor(R.color.nliveo_white));
    searchView.setOnQueryTextListener(onQuerySearchView);

    menu.findItem(R.id.menu_add).setVisible(true);

    mSearchCheck = false;/*w  w  w .  j ava 2 s  .  c om*/
}

From source file:com.keylesspalace.tusky.ViewThreadActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.view_thread_toolbar, menu);
    MenuItem menuItem = menu.findItem(R.id.action_reveal);
    menuItem.setVisible(revealButtonState != REVEAL_BUTTON_HIDDEN);
    menuItem.setIcon(/*w w w  . j av  a2  s .  c om*/
            revealButtonState == REVEAL_BUTTON_REVEAL ? R.drawable.ic_eye_24dp : R.drawable.ic_hide_media_24dp);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.justplay1.shoppist.features.category.CategoriesActivity.java

@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
    super.onPrepareActionMode(actionMode, menu);
    MenuItem delete = menu.findItem(R.id.menu_delete);
    delete.setVisible(fragment.isDeleteButtonEnable());

    MenuItem checkAll = menu.findItem(R.id.menu_check_all);
    checkAll.setEnabled(fragment.isCheckAllButtonEnable());
    return true;/*  w  ww  . j  a  v a  2s . c o  m*/
}

From source file:com.luorrak.ouroboros.catalog.BoardListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_catalog, menu);
    MenuItem addBoard = menu.findItem(R.id.action_add_board);
    addBoard.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.bdenney.locl.activity.NearbyActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the options menu from XML
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default

    if (!TextUtils.isEmpty(getSearchTerm())) {
        final MenuItem item = menu.findItem(R.id.menu_search);
        if (item != null) {
            item.setVisible(false);
        }/*w  w  w.ja  v  a2  s. com*/
    }

    return true;
}

From source file:com.btmura.android.reddit.app.ThingTableMenuController.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    String subreddit = getSubreddit();

    boolean hasAccount = AccountUtils.isAccount(accountName);
    boolean hasSubreddit = subreddit != null;
    boolean hasThing = thingHolder != null && thingHolder.isShowingThing();
    boolean hasSidebar = Subreddits.hasSidebar(subreddit);
    boolean isSubreddit = hasSubreddit && !hasThing;

    boolean showNewPost = isSubreddit && hasAccount;
    boolean showSubreddit = isSubreddit && hasSidebar;
    boolean showRefresh = !hasThing;

    menu.findItem(R.id.menu_add_subreddit).setVisible(isSubreddit);
    menu.findItem(R.id.menu_new_post).setVisible(showNewPost);
    menu.findItem(R.id.menu_refresh).setVisible(showRefresh);

    MenuItem subredditItem = menu.findItem(R.id.menu_subreddit);
    subredditItem.setVisible(showSubreddit);
    if (showSubreddit) {
        subredditItem.setTitle(MenuHelper.getSubredditTitle(ctx, subreddit));
    }//from  w w  w .j a  va2 s. c  om
}

From source file:android.hawkencompanionapp.activities.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.login, menu);
    final MenuItem menuItemSignOut = menu.findItem(R.id.action_sign_out);
    final MenuItem menuItemOfflineMode = menu.findItem(R.id.action_offline_mode);

    //Disable the About option if the current activity is the About activity
    if (this instanceof AboutActivity) {
        final MenuItem about = menu.findItem(R.id.action_about);
        final int len = menu.size();
        //Disable all menu items when the about activity is being shown.
        for (int i = 0; i < len; i++) {
            final MenuItem item = menu.getItem(i);
            item.setVisible(false);
        }/*from   w ww.j  a v  a 2  s  .c om*/
    } else if (this instanceof ForgotPasswordActvity) { //Forgot Password activity is shown
        menuItemSignOut.setVisible(false);
        menuItemOfflineMode.setVisible(false);
    } else if (this instanceof LoginActivity) { //Login activity is shown
        menuItemSignOut.setVisible(false);
    } else if (this instanceof UserAccountMainActivity) {
        menuItemOfflineMode.setVisible(false);
    }

    if (mDisableSignOutOption) { //If the user is in offline mode
        menuItemSignOut.setVisible(false);
    }

    return true;
}

From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPFiltersFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuItem searchBtn = menu.findItem(R.id.action_search);
    searchBtn.setVisible(false);

    ((MainActivity) getActivity()).closeSearch();

    MenuItem clearFiltersItem = menu.add(getResources().getString(R.string.btn_clear_filters));
    clearFiltersItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_times)
            .colorRes(R.color.accentNoTransparency).actionBarSize());
    clearFiltersItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    clearFiltersItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override// ww w  .j a v  a  2s . c  o m
        public boolean onMenuItemClick(MenuItem item) {
            Toast.makeText(getActivity(), "Filters cleared", Toast.LENGTH_SHORT).show();

            try {
                DBManager.setAllCategoriesSelected(false);
            } catch (SQLException e) {
                e.printStackTrace();
            }

            ((FiltersCellAdapter) recyclerView.getAdapter()).refreshData();

            synchronized (RHCareerFairLayout.refreshCompaniesNotifier) {
                RHCareerFairLayout.refreshCompaniesNotifier.notifyChanged();
            }

            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    recyclerView.getAdapter().notifyDataSetChanged();
                }
            });

            return true;
        }
    });
}

From source file:com.nadmm.airports.PreferencesActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem settings = menu.findItem(R.id.menu_settings);
    settings.setVisible(false);

    return super.onPrepareOptionsMenu(menu);
}