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:anastasoft.rallyvision.activity.MenuPrincipal.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem aMenuItem = menu.findItem(R.id.action_slider_carregar_trecho);
    if (aMenuItem != null) {
        aMenuItem.setVisible(isSliderActive);

    }/*from   w w w.  j  a  va  2  s. c o m*/

    aMenuItem = menu.findItem(R.id.action_slider_agendar_prova);
    if (aMenuItem != null) {
        //                    aMenuItem.setVisible(true);
        aMenuItem.setVisible(isAgendamentoInicioProvaSliderActive);

    }
    return super.onPrepareOptionsMenu(menu);

}

From source file:com.sbgapps.scoreit.ScoreItActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (null != mLap)
        return true;

    int lapCnt = mGameManager.getLaps().size();
    int game = mGameManager.getPlayedGame();

    MenuItem item;
    item = menu.findItem(R.id.menu_chart);
    item.setVisible(isPhone() && 0 != lapCnt);

    item = menu.findItem(R.id.menu_clear);
    item.setVisible(0 != lapCnt);/* ww  w.  j  a v a 2 s. c om*/

    item = menu.findItem(R.id.menu_round);
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    boolean round;
    switch (game) {
    default:
        item.setVisible(false);
        break;
    case Game.BELOTE:
        round = sp.getBoolean(GameManager.KEY_BELOTE_ROUND, false);
        item.setTitle(round ? R.string.menu_action_actual_scores : R.string.menu_action_round_scores);
        break;
    case Game.COINCHE:
        round = sp.getBoolean(GameManager.KEY_COINCHE_ROUND, false);
        item.setTitle(round ? R.string.menu_action_actual_scores : R.string.menu_action_round_scores);
        break;
    }

    item = menu.findItem(R.id.menu_count);
    item.setVisible(Game.UNIVERSAL == game || Game.TAROT == game);

    item = menu.findItem(R.id.menu_save);
    List<String> files = mGameManager.getFileHelper().getSavedFiles();
    item.setVisible(0 != files.size());

    item = menu.findItem(R.id.menu_total);
    item.setVisible(Game.UNIVERSAL == game);

    return true;
}

From source file:com.tt.jobtracker.MainActivity.java

public void SetActionBarMenuItems() {
    if (menu == null)
        return;//ww  w  .  ja v a  2  s . co m

    menu.setGroupVisible(R.id.actionbar_group_home, false);
    menu.setGroupVisible(R.id.actionbar_group_taskdetail, false);
    menu.setGroupVisible(R.id.actionbar_group_tasklineitem_detail, false);
    menu.setGroupVisible(R.id.actionbar_Admin_group_home, false);

    switch (CurrentScreen) {
    case TaskList:
        /* if(Shared.hideMenu=="true")
        {
            menu.setGroupVisible(R.id.actionbar_group_home, false);
        }
        else {*/
        menu.setGroupVisible(R.id.actionbar_group_home, true);
        //}
        break;
    case TaskDetail:
        if (Shared.hideMenu == "true") {
            menu.setGroupVisible(R.id.actionbar_group_taskdetail, false);

        } else {

            menu.setGroupVisible(R.id.actionbar_group_taskdetail, true);
            if (Shared.SelectedTask != null) {
                int value = dbHelper.PhotoUploadCount(Shared.SelectedTask.ID);
                if (value <= 0) {
                    MenuItem item = menu.findItem(R.id.action_task_done);
                    item.setVisible(true);
                    this.invalidateOptionsMenu();
                } else {
                    MenuItem item = menu.findItem(R.id.action_task_done);
                    item.setVisible(false);
                    this.invalidateOptionsMenu();
                }
            }
        }
        break;
    case TaskLineItemDetail:
        if (Shared.hideMenu == "true") {
            menu.setGroupVisible(R.id.actionbar_group_tasklineitem_detail, false);
        } else {
            menu.setGroupVisible(R.id.actionbar_group_tasklineitem_detail, true);
        }
        break;
    case Setting:
        break;
    }
}

From source file:com.pressurelabs.flowopensource.TheHubActivity.java

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    menu.clear();/*  w  ww. j ava 2s .  c o  m*/
    getMenuInflater().inflate(R.menu.menu_the_hub, menu);

    MenuItem newF = menu.findItem(R.id.action_new_flow);
    MenuItem deleteAllF = menu.findItem(R.id.action_delete_flows);
    if (menuState.equals(AppConstants.MENU_ITEMS_HIDE)) {
        newF.setVisible(false);
        deleteAllF.setVisible(false);
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.example.linhdq.test.documents.viewing.grid.DocumentGridActivity.java

@Override
public void onCheckedChanged(Set<Integer> checkedIds) {
    if (mActionMode == null && checkedIds.size() > 0) {
        mActionMode = startSupportActionMode(new DocumentActionCallback());
    } else if (mActionMode != null && checkedIds.size() == 0) {
        mActionMode.finish();//w  w w.jav  a 2  s.  co m
        mActionMode = null;
    }

    if (mActionMode != null) {
        // change state of action mode depending on the selection
        final MenuItem editItem = mActionMode.getMenu().findItem(R.id.item_edit_title);
        final MenuItem joinItem = mActionMode.getMenu().findItem(R.id.item_join);
        if (checkedIds.size() == 1) {
            editItem.setVisible(true);
            editItem.setEnabled(true);
            joinItem.setVisible(false);
            joinItem.setEnabled(false);
        } else {
            editItem.setVisible(false);
            editItem.setEnabled(false);
            joinItem.setVisible(true);
            joinItem.setEnabled(true);
        }
    }
}

From source file:org.creativecommons.thelist.misc.MainActivity.java

private void updateMenuTitles() {
    MenuItem switchAccounts = menu.findItem(R.id.switch_accounts);

    if (mCurrentUser.getAccountCount() > 0) {
        switchAccounts.setVisible(false);
        //TODO: uncomment when Switch Accounts works
        //switchAccounts.setTitle("Switch Accounts");
    } else {//w  w w .  ja  v a 2  s .  c  o  m
        switchAccounts.setTitle("Add Account");
    }
}

From source file:com.nextgis.mobile.activity.MainActivity.java

public void showEditToolbar() {
    stopRefresh(mToolbar.getMenu().findItem(R.id.menu_refresh));
    mToolbar.getMenu().clear();/* www .ja v  a  2s .  co  m*/
    mToolbar.inflateMenu(R.menu.edit_geometry);

    MenuItem item = mToolbar.getMenu().findItem(com.nextgis.maplibui.R.id.menu_edit_redo);
    boolean visible = mMapFragment.getMode() != MapFragment.MODE_EDIT_BY_WALK;
    item.setVisible(visible);
    item = mToolbar.getMenu().findItem(com.nextgis.maplibui.R.id.menu_edit_undo);
    item.setVisible(visible);

    mLayersFragment.setDrawerToggleEnabled(false);
    mToolbar.setNavigationIcon(R.drawable.ic_action_cancel_dark);
}

From source file:com.downrighttech.dmxdip.MainActivity.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override/*from  w ww.j a  v  a  2  s  .c o m*/
public boolean onCreateOptionsMenu(Menu menu) {
    Log.v(TAG, "onCreateOptionsMenu-" + menu.toString());
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);

    MenuItem shareMenuItem = menu.findItem(R.id.menu_share);
    if (VERSION.SDK_INT >= 14) {

        // get Action Provider from XML
        mShareActionProvider = (ShareActionProvider) shareMenuItem.getActionProvider();

        //Setup shareIntent
        mShareIntent = new Intent(Intent.ACTION_SEND);
        mShareIntent.setType("text/plain");
    } else
        shareMenuItem.setVisible(false);

    return true;
}

From source file:com.sbgapps.scoreit.ui.ScoreItActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (mDrawerLayout.isDrawerOpen(mNavigationDrawer) || (null != mLap)) {
        return false;
    }//from w w  w  . j a  va  2  s . c  om

    int lapCnt = mGameHelper.getLaps().size();
    int game = mGameHelper.getPlayedGame();

    MenuItem item;
    item = menu.findItem(R.id.menu_view);
    item.setVisible(!isTablet() && 0 != lapCnt);

    item = menu.findItem(R.id.menu_clear);
    item.setVisible(0 != lapCnt);

    item = menu.findItem(R.id.menu_count);
    item.setVisible(Game.UNIVERSAL == game || Game.TAROT == game);

    item = menu.findItem(R.id.menu_save);
    List<String> files = mGameHelper.getFilesUtil().getSavedFiles();
    item.setVisible(0 != files.size());

    item = menu.findItem(R.id.menu_total);
    item.setVisible(Game.UNIVERSAL == game);

    return true;
}

From source file:de.enlightened.peris.PostsFragment.java

public final void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) {
    //Block profile viewing on restricted accounts
    final SharedPreferences appPreferences = this.activity.getSharedPreferences("prefs", 0);
    final boolean accountRestricted = appPreferences.getBoolean(this.storagePrefix + "logged_banned", false);
    if (accountRestricted) {
        return;//from   www  . ja  v  a  2 s.  c o m
    }

    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    this.selectedPost = (Post) this.mainList.getItemAtPosition(info.position);

    super.onCreateContextMenu(menu, v, menuInfo);
    final MenuInflater inflater = this.activity.getMenuInflater();
    inflater.inflate(R.menu.posts_context, menu);

    if (this.userid != null) {
        final MenuItem item3 = menu.findItem(R.id.posts_quote);
        item3.setVisible(true);

        final MenuItem item5 = menu.findItem(R.id.posts_message);
        item5.setVisible(true);
    }

    if (this.selectedPost.authorId != null) {
        if (this.selectedPost.authorId.equals(this.userid)) {
            final MenuItem item5 = menu.findItem(R.id.posts_message);
            item5.setVisible(false);
        }
    }

    final MenuItem itemBan = menu.findItem(R.id.posts_context_ban);
    final MenuItem itemDelete = menu.findItem(R.id.posts_context_delete);
    final MenuItem itemEdit = menu.findItem(R.id.posts_edit);
    final MenuItem itemThank = menu.findItem(R.id.posts_thank);
    final MenuItem itemLike = menu.findItem(R.id.posts_like);

    if (this.selectedPost.canThank) {
        itemThank.setVisible(true);
    } else {
        itemThank.setVisible(false);
    }

    if (this.selectedPost.canLike) {
        itemLike.setVisible(true);
    } else {
        itemLike.setVisible(false);
    }

    if (this.selectedPost.canBan && !this.selectedPost.userBanned) {
        itemBan.setVisible(true);
    } else {
        itemBan.setVisible(false);
    }

    if (this.selectedPost.canDelete) {
        itemDelete.setVisible(true);
    } else {
        itemDelete.setVisible(false);
    }

    if (this.selectedPost.canEdit) {
        itemEdit.setVisible(true);
    } else {
        itemEdit.setVisible(false);
    }
}