Example usage for android.view MenuItem SHOW_AS_ACTION_NEVER

List of usage examples for android.view MenuItem SHOW_AS_ACTION_NEVER

Introduction

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

Prototype

int SHOW_AS_ACTION_NEVER

To view the source code for android.view MenuItem SHOW_AS_ACTION_NEVER.

Click Source Link

Document

Never show this item as a button in an Action Bar.

Usage

From source file:net.simonvt.cathode.ui.fragment.EpisodeFragment.java

private void createMenu(Toolbar toolbar) {
    Menu menu = toolbar.getMenu();
    menu.clear();//from  w  ww . j  a  v  a2  s  .  c  o m

    toolbar.inflateMenu(R.menu.activity_base);

    if (loaded) {
        if (checkedIn) {
            menu.add(0, R.id.action_checkin_cancel, 1, R.string.action_checkin_cancel)
                    .setIcon(R.drawable.ic_action_cancel).setShowAsActionFlags(
                            isTablet ? MenuItem.SHOW_AS_ACTION_NEVER : MenuItem.SHOW_AS_ACTION_ALWAYS);
        } else if (!watching) {
            menu.add(0, R.id.action_checkin, 2, R.string.action_checkin).setIcon(R.drawable.ic_action_checkin)
                    .setShowAsActionFlags(
                            isTablet ? MenuItem.SHOW_AS_ACTION_NEVER : MenuItem.SHOW_AS_ACTION_ALWAYS);
        }

        if (watched) {
            menu.add(0, R.id.action_unwatched, 3, R.string.action_unwatched);
        } else {
            menu.add(0, R.id.action_watched, 4, R.string.action_watched);
            if (inWatchlist) {
                menu.add(0, R.id.action_watchlist_remove, 5, R.string.action_watchlist_remove);
            } else {
                menu.add(0, R.id.action_watchlist_add, 6, R.string.action_watchlist_add);
            }
        }

        if (collected) {
            menu.add(0, R.id.action_collection_remove, 7, R.string.action_collection_remove);
        } else {
            menu.add(0, R.id.action_collection_add, 8, R.string.action_collection_add);
        }
    }
}

From source file:com.money.manager.ex.account.AccountTransactionListFragment.java

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

    //force show add transaction
    MenuItem itemAddTransaction = menu.findItem(R.id.menu_add_transaction_account);
    if (itemAddTransaction != null)
        itemAddTransaction.setVisible(true);
    //manage dual panel
    if (getActivity() != null && getActivity() instanceof MainActivity) {
        MainActivity activity = (MainActivity) getActivity();
        if (!activity.isDualPanel()) {
            //hide sync toolbar
            MenuItem itemSync = menu.findItem(R.id.menu_sync);
            if (itemSync != null)
                itemSync.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

            // hide menu open database
            MenuItem itemOpenDatabase = menu.findItem(R.id.menu_open_database);
            if (itemOpenDatabase != null) {
                //itemOpenDatabase.setVisible(isShownOpenDatabaseItemMenu());
                itemOpenDatabase.setShowAsAction(
                        !itemSync.isVisible() ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER);
            }//from   w ww . j a  v a2s. c o m

            //hide dash board
            MenuItem itemDashboard = menu.findItem(R.id.menu_dashboard);
            if (itemDashboard != null)
                itemDashboard.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
    }

    selectCurrentPeriod(menu);
    selectCurrentStatus(menu);
}

From source file:tkj.android.homecontrol.mythmote.MythMote.java

/**
 * Called to create the options menu once.
 *//*from   www  . ja  va  2 s .  com*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);

    // create reconnect menu item
    MenuItem menuItem = menu.add(0, RECONNECT_ID, 0, R.string.reconnect_str)
            .setIcon(R.drawable.ic_menu_refresh);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }

    // create settings menu item
    menuItem = menu.add(0, SETTINGS_ID, 0, R.string.settings_menu_str)
            .setIcon(android.R.drawable.ic_menu_preferences);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    // create keyboard input menu item
    menuItem = menu.add(0, KEYBOARD_INPUT_ID, 0, R.string.keyboard_input_str)
            .setIcon(R.drawable.ic_notification_ime_default);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    // create select location menu item
    menuItem = menu.add(0, SELECTLOCATION_ID, 0, R.string.selected_location_str)
            .setIcon(R.drawable.ic_menu_home);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    //create wake on lan menu item
    menuItem = menu.add(0, SENDWOL_ID, 0, R.string.send_wol_str).setIcon(R.drawable.ic_menu_sun);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    }
    //menu.add(0, SENDWOL_RE_ID, 0, R.string.send_wol_re_str);
    //menu.add(0, SENDWOL_PJ_ID, 0, R.string.send_wol_pj_str);

    //add donate button if enabled
    if (sShowDonateMenuItem) {

    }

    // return results
    return result;
}

From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.FileExplorerAdapter.java

public void getMenu(Menu menu, File f) {
    MenuItem mi;/*  w w w  .  j  a  v a2s .  c  o m*/

    if (f.isFile()) {
        mi = menu.add(Menu.NONE, R.id.menu_action_share, Menu.FIRST, R.string.share);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

        mi = menu.add(Menu.NONE, R.id.menu_upload, Menu.FIRST + 30, R.string.upload);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    if (f.canWrite() && downloadPath != null && f.getPath().startsWith(downloadPath)) {
        mi = menu.add(Menu.NONE, R.id.menu_action_edit, Menu.FIRST + 50, R.string.action_rename);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

        mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 100, R.string.delete);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    if (DataProtectionManager.getInstance(getContext()).isEncryptionEnable()) {
        if (DataProtectionManager.getInstance(getContext()).isEncrypted(f.getPath())) {
            mi = menu.add(Menu.NONE, R.id.menu_file_decrypt, Menu.FIRST + 70, R.string.decrypt_action);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        } else {
            mi = menu.add(Menu.NONE, R.id.menu_file_encrypt, Menu.FIRST + 70, R.string.encrypt_action);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
        }
    }

}

From source file:com.paranoid.gerrit.GerritControllerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.gerrit_instances_menu, menu);
    this.mMenu = menu;

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(true);
    // Let the change list fragment handle queries directly.
    searchView.setOnQueryTextListener(mChangeList);
    searchView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override//from   ww  w  . j a  v a 2  s . co  m
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {
            SearchView view = (SearchView) v;
            if (view.isIconified()) {
                mMenu.findItem(R.id.menu_team_instance).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
                mMenu.findItem(R.id.menu_projects).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            } else {
                mMenu.findItem(R.id.menu_team_instance).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
                mMenu.findItem(R.id.menu_projects).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
            }
        }
    });

    setupSearchQuery();
    return true;
}

From source file:nl.sogeti.android.gpstracker.actions.Statistics.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);
    MenuItem item;/*from  w w  w . ja v a  2s. c o m*/
    item = menu.add(ContextMenu.NONE, MENU_SHARE, ContextMenu.NONE, R.string.menu_shareTrack)
            .setIcon(R.drawable.ic_share_24dp).setAlphabeticShortcut('s');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);
    item = menu.add(ContextMenu.NONE, MENU_TRACKLIST, ContextMenu.NONE, R.string.menu_tracklist)
            .setIcon(R.drawable.ic_list_24dp).setAlphabeticShortcut('l');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);
    item = menu.add(ContextMenu.NONE, MENU_GRAPHTYPE, ContextMenu.NONE, R.string.menu_graphtype)
            .setIcon(R.drawable.ic_graph_24dp).setAlphabeticShortcut('t');
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_NEVER);
    return result;
}

From source file:com.koushikdutta.superuser.FragmentMain.java

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

    MenuItem mode = menu.add(Menu.NONE, Menu.NONE, 100, R.string.list_mode);
    mode.setTitle(pref.getBoolean("grid_mode", true) ? R.string.list_mode : R.string.grid_mode);
    mode.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    mode.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override/*from   w  ww . j  a va 2  s  . c  om*/
        public boolean onMenuItemClick(MenuItem menuItem) {

            if (pref.edit().putBoolean("grid_mode", !pref.getBoolean("grid_mode", true)).commit())
                getActivity().recreate();
            return true;
        }
    });

    if (!gridMode)
        return;

    MenuItem gridSize = menu.add(Menu.NONE, Menu.NONE, 101, R.string.grid_size);
    gridSize.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    gridSize.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {

            int sizePort = pref.getInt("grid_size_port", 3);
            int sizeLand = pref.getInt("grid_size_land", 4);

            final AlertDialog.Builder builder = new AlertDialog.Builder(context);

            View parent = LayoutInflater.from(context).inflate(R.layout.dialog_settings_grid_size, null);

            final AppCompatSeekBar seekPort = (AppCompatSeekBar) parent.findViewById(R.id.seek_port);
            seekPort.setProgress(sizePort - 3);

            final AppCompatSeekBar seekLand = (AppCompatSeekBar) parent.findViewById(R.id.seek_land);
            seekLand.setProgress(sizeLand - 3);

            builder.setView(parent);
            builder.setPositiveButton("?", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    SharedPreferences.Editor editor = pref.edit();

                    editor.putInt("grid_size_port", seekPort.getProgress() + 3);
                    editor.putInt("grid_size_land", seekLand.getProgress() + 3).apply();

                    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
                        int val = seekPort.getProgress() + 3;
                        layoutManager.setSpanCount(val);
                        callback.onGridSpanChanged(type, val);

                    } else if (getResources()
                            .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
                        int val = seekLand.getProgress() + 3;
                        layoutManager.setSpanCount(val);
                        callback.onGridSpanChanged(type, val);
                    }
                }
            });

            builder.show();
            return true;
        }
    });
}

From source file:org.uguess.android.sysinfo.NetStateManager.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem mi = menu.add(Menu.NONE, MI_PREFERENCE, Menu.NONE, R.string.preference);
    mi.setIcon(android.R.drawable.ic_menu_preferences);
    Util.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_NEVER);
}

From source file:net.lp.actionbarpoirot.actions.UiAction.java

/**
 * Destructor/*from   w  w  w .jav a2  s  .c o m*/
 */
public void destruct() {
    this.showActionOnCompatActionBar = false;
    this.showActionWhenMultipleSelected = false;
    this.clientReference = null;
    this.menuItemAndRequestCodeId = -1;
    this.showActionEnum = MenuItem.SHOW_AS_ACTION_NEVER;
}

From source file:com.abewy.android.apps.klyph.app.MainActivity.java

public boolean onCreateOptionsMenu(Menu menu) {
    if (notificationsFragment != null && menu.findItem(R.id.menu_notifications) == null) {
        final MenuItem notificationItem = menu.add(Menu.NONE, R.id.menu_notifications, 2,
                R.string.menu_notifications);
        notificationItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        notificationItem.setActionView(R.layout.actionbar_item_notifications);

        final TextView notificationTextView = (TextView) notificationItem.getActionView()
                .findViewById(R.id.textView);

        int count = notificationsFragment.getUnreadCount();

        notificationTextView.setText(String.valueOf(count));

        if (count > 0) {
            notificationTextView/* ww  w. ja  va2  s.  co  m*/
                    .setBackgroundResource(AttrUtil.getResourceId(this, R.attr.notificationsItemBackground));
        } else {
            notificationTextView.setBackgroundResource(R.drawable.notifications_read_background);

        }

        notificationItem.getActionView().setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                onOptionsItemSelected(notificationItem);
            }
        });
    }

    if (!KlyphFlags.IS_PRO_VERSION && menu.findItem(R.id.menu_buy_pro) == null) {
        menu.add(Menu.NONE, R.id.menu_buy_pro, 2, R.string.menu_buy_pro)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    if (menu.findItem(R.id.menu_faq) == null) {
        menu.add(Menu.NONE, R.id.menu_faq, Menu.NONE, R.string.menu_faq)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    return super.onCreateOptionsMenu(menu);
}