Example usage for android.view MenuItem setChecked

List of usage examples for android.view MenuItem setChecked

Introduction

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

Prototype

public MenuItem setChecked(boolean checked);

Source Link

Document

Control whether this item is shown with a check mark.

Usage

From source file:mroza.forms.ChooseProgramActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.sync_now:
        syncData();// w  w  w .j  a  v a  2 s . com
        return true;
    case R.id.sync_date:
        showLastSyncDate();
        return true;
    case R.id.teaching_ended:
    case R.id.teaching_not_started:
    case R.id.teaching_saved:
    case R.id.general_ended:
    case R.id.general_not_started:
    case R.id.general_saved:
        if (item.isChecked()) {
            item.setChecked(false);
            selectedFilters.remove(item);
        } else {
            item.setChecked(true);
            selectedFilters.add(item);
            letterFilter = null;
        }
        filterPrograms();
        return true;
    case R.id.choose_letter_A:
    case R.id.choose_letter_B:
    case R.id.choose_letter_C:
    case R.id.choose_letter_D:
    case R.id.choose_letter_E:
    case R.id.choose_letter_F:
    case R.id.choose_letter_G:
    case R.id.choose_letter_H:
    case R.id.choose_letter_I:
    case R.id.choose_letter_J:
    case R.id.choose_letter_K:
    case R.id.choose_letter_L:
    case R.id.choose_letter_M:
    case R.id.choose_letter_N:
    case R.id.choose_letter_O:
    case R.id.choose_letter_P:
    case R.id.choose_letter_Q:
    case R.id.choose_letter_R:
    case R.id.choose_letter_S:
    case R.id.choose_letter_T:
    case R.id.choose_letter_U:
    case R.id.choose_letter_V:
    case R.id.choose_letter_W:
    case R.id.choose_letter_X:
    case R.id.choose_letter_Y:
    case R.id.choose_letter_Z:
        if (item.isChecked()) {
            item.setChecked(false);
            letterFilter = null;
        } else {
            item.setChecked(true);
            letterFilter = item;
        }
        filterPrograms();
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.abhijitvalluri.android.fitnotifications.AppChoicesActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.app_search, menu);

    MenuItem searchItem = menu.findItem(R.id.menu_app_search);
    MenuItem filterEnabledAppsItem = menu.findItem(R.id.menu_filter_enabled);

    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getString(R.string.search_query_hint));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override/*from  w  w  w  .ja  va 2 s  .  co  m*/
        public boolean onQueryTextSubmit(String query) {
            return recyclerViewShowSearchResult(query);
        }

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

    searchItem.setEnabled(false);
    filterEnabledAppsItem.setEnabled(false);
    filterEnabledAppsItem.setChecked(mShowOnlyEnabledApps);

    return true;
}

From source file:cn.zhangls.android.weibo.ui.message.mention.MentionActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        onBackPressed();// w ww.ja v a 2  s .  co  m
        return true;
    } else if (item.isChecked()) {
        return super.onOptionsItemSelected(item);
    }
    switch (item.getItemId()) {
    case R.id.menu_ac_msg_all_weibo:
        mWeiboListType = WeiboListType.ALL_WEIBO;
        break;
    case R.id.menu_ac_msg_following_weibo:
        mWeiboListType = WeiboListType.FOLLOWING_WEIBO;
        break;
    case R.id.menu_ac_msg_original_weibo:
        mWeiboListType = WeiboListType.ORIGINAL_WEIBO;
        break;
    case R.id.menu_ac_msg_all_comment:
        mWeiboListType = WeiboListType.ALL_COMMENT;
        break;
    case R.id.menu_ac_msg_following_comment:
        mWeiboListType = WeiboListType.FOLLOWING_COMMENT;
        break;
    }
    item.setChecked(true);
    onRefresh();
    showProgressDialog();

    return true;
}

From source file:com.bar.foldinglayout.sample.FoldingLayoutActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.animate_fold:
        animateFold();// w w w  .ja  v  a2  s . c o  m
        break;
    case R.id.toggle_orientation:
        mOrientation = (mOrientation == BaseFoldingLayout.Orientation.HORIZONTAL)
                ? BaseFoldingLayout.Orientation.VERTICAL
                : BaseFoldingLayout.Orientation.HORIZONTAL;
        item.setTitle((mOrientation == BaseFoldingLayout.Orientation.HORIZONTAL) ? R.string.vertical
                : R.string.horizontal);
        // mTranslation = 0;
        mFoldLayout.setOrientation(mOrientation);
        break;
    case R.id.camera_feed:
        if (IS_ISC) {
            mIsCameraFeed = !mIsCameraFeed;
            item.setTitle(mIsCameraFeed ? R.string.static_image : R.string.camera_feed);
            item.setChecked(mIsCameraFeed);
            if (mIsCameraFeed) {
                //   mFoldLayout.removeView(mImageView);
                //   mFoldLayout.addView(mTextureView,
                //      new ViewGroup.LayoutParams(mFoldLayout.getWidth(),
                //            mFoldLayout.getHeight()));
            } else {
                //mFoldLayout.removeView(mTextureView);
                //mFoldLayout.addView(mImageView, new ViewGroup.LayoutParams(
                //      mFoldLayout.getWidth(), mFoldLayout.getHeight()));
            }
            // mTranslation = 0;
        }
        break;
    case R.id.sepia:
        mIsSepiaOn = !mIsSepiaOn;
        item.setChecked(mIsSepiaOn);
        if (mIsSepiaOn && mFoldLayout.getFoldFactor() != 0) {
            setSepiaLayer(mFoldLayout.getChildAt(0), true);
        } else {
            setSepiaLayer(mFoldLayout.getChildAt(0), false);
        }
        break;
    default:
        break;

    }
    return super.onOptionsItemSelected(item);
}

From source file:com.stoutner.privacybrowser.MainWebViewActivity.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.menu_options, menu);

    // Set mainMenu so it can be used by onOptionsItemSelected.
    mainMenu = menu;/*  ww w  . j  a  va2s.  c o  m*/

    // Initialize privacyIcon
    privacyIcon = menu.findItem(R.id.toggleJavaScript);

    // Get MenuItems for checkable menu items.
    MenuItem toggleFirstPartyCookies = menu.findItem(R.id.toggleFirstPartyCookies);
    MenuItem toggleThirdPartyCookies = menu.findItem(R.id.toggleThirdPartyCookies);
    MenuItem toggleDomStorage = menu.findItem(R.id.toggleDomStorage);

    // Set the initial status of the privacy icon.
    updatePrivacyIcon();

    // Set the initial status of the menu item checkboxes.
    toggleFirstPartyCookies.setChecked(firstPartyCookiesEnabled);
    toggleThirdPartyCookies.setChecked(thirdPartyCookiesEnabled);
    toggleDomStorage.setChecked(domStorageEnabled);

    return true;
}

From source file:com.nononsenseapps.feeder.ui.FeedFragment.java

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

    if (id < 1) {
        menu.findItem(R.id.action_edit_feed).setVisible(false);
        menu.findItem(R.id.action_delete_feed).setVisible(false);
        menu.findItem(R.id.action_add_templated).setVisible(false);
    }/*  w w  w.  j  a v a  2 s  .  c o m*/

    // Set toggleable state
    MenuItem menuItem = menu.findItem(R.id.action_only_unread);
    final boolean onlyUnread = PrefUtils.isShowOnlyUnread(getActivity());
    menuItem.setChecked(onlyUnread);
    menuItem.setTitle(onlyUnread ? R.string.show_unread_items : R.string.show_all_items);
    if (onlyUnread) {
        menuItem.setIcon(R.drawable.ic_action_visibility_off);
    } else {
        menuItem.setIcon(R.drawable.ic_action_visibility);
    }

    // Don't forget super call here
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:chaitanya.im.searchforreddit.LauncherActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_refresh:
        initializeSearch();/*from w  w w  .jav a  2  s  .  c  o  m*/
        return true;

    case R.id.action_donate:
        dialog.setWhichDialog(0);
        dialog.setPurchaseDialog(-1);
        dialog.show(getSupportFragmentManager(), "tag");
        return true;

    case R.id.action_dark:
        if (donate == 1) {
            isChecked = !(item.isChecked());
            item.setChecked(isChecked);
            if (isChecked)
                UtilMethods.changeToTheme(this, 1, sharedPref);
            else
                UtilMethods.changeToTheme(this, 0, sharedPref);
            return true;
        } else {
            dialog.setWhichDialog(0);
            dialog.setPurchaseDialog(1);
            dialog.show(getSupportFragmentManager(), "tag");
            return true;
        }

    case R.id.action_licenses:
        dialog.setWhichDialog(1);
        dialog.show(getSupportFragmentManager(), "tag");
        return true;

    case R.id.action_about:
        dialog.setWhichDialog(2);
        dialog.show(getSupportFragmentManager(), "tag");
        return true;

    case R.id.action_whats_new:
        dialog.setWhichDialog(3);
        dialog.show(getSupportFragmentManager(), "tag");
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.almarsoft.GroundhogReader.MessageListActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem showRead = menu.findItem(R.id.messagelist_menu_showread);
    boolean showReadValue = mPrefs.getBoolean("showRead", false);
    showRead.setChecked(showReadValue);

    if (showReadValue)
        showRead.setTitle(R.string.msglist_group_hideread);
    else//from   ww w  .j  av a  2  s  .c  o  m
        showRead.setTitle(R.string.msglist_group_showread);

    return (super.onPrepareOptionsMenu(menu));
}

From source file:com.morlunk.mumbleclient.channel.ChannelListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.menu_mute_button: {
        IUser self = getService().getSessionUser();

        boolean muted = !self.isSelfMuted();
        boolean deafened = self.isSelfDeafened();
        deafened &= muted; // Undeafen if mute is off
        getService().setSelfMuteDeafState(muted, deafened);

        getActivity().supportInvalidateOptionsMenu();
        return true;
    }//from   w  w w . j av a 2  s .  c  o  m
    case R.id.menu_deafen_button: {
        IUser self = getService().getSessionUser();

        boolean deafened = !self.isSelfDeafened();
        getService().setSelfMuteDeafState(deafened, deafened);

        getActivity().supportInvalidateOptionsMenu();
        return true;
    }
    case R.id.menu_search:
        return false;
    case R.id.menu_bluetooth:
        item.setChecked(!item.isChecked());
        if (item.isChecked()) {
            getService().enableBluetoothSco();
        } else {
            getService().disableBluetoothSco();
        }
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:info.corne.performancetool.MainActivity.java

private void applySetOnBoot(MenuItem item) {
    onBootEnabled = !onBootEnabled;// ww w  .j av  a  2s .c  o m
    SharedPreferences pm = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());
    Editor ed = pm.edit();
    ed.putBoolean(Settings.SET_ON_BOOT_SETTING, onBootEnabled);
    ed.commit();
    item.setChecked(onBootEnabled);
}