当前位置: 首页>>代码示例>>Java>>正文


Java MenuItem.setChecked方法代码示例

本文整理汇总了Java中android.view.MenuItem.setChecked方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setChecked方法的具体用法?Java MenuItem.setChecked怎么用?Java MenuItem.setChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.MenuItem的用法示例。


在下文中一共展示了MenuItem.setChecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
/**
 * Invoked only once during app's lifetime. For successive calls see
 * {@link #onPrepareOptionsMenu(Menu)}. Both used primarily to determine checkboxes for tracking
 * and detection.
 *
 * Because the service may not available on app boot, we default to false until the service
 * boots. Once that occurs, the checkboxes are driven by the service's status.
 *
 * @param menu
 * @return
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    MenuItem toggleAttackDetectionMenuItem = menu.findItem(R.id.toggle_attack_detection);
    MenuItem toggleCellTrackingMenuItem = menu.findItem(R.id.toggle_cell_tracking);

    // The service may not exist on first app boot. Choose sane defaults
    if (mAimsicdService == null) {
        toggleAttackDetectionMenuItem.setChecked(false);
        toggleCellTrackingMenuItem.setChecked(false);
    } else {
        toggleAttackDetectionMenuItem.setChecked(mAimsicdService.isMonitoringCell());
        toggleCellTrackingMenuItem.setChecked(mAimsicdService.isTrackingCell());
    }
    return true;
}
 
开发者ID:5GSD,项目名称:AIMSICDL,代码行数:30,代码来源:MainActivity.java

示例2: onOptionsItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if(item.getItemId() == R.id.action_wrap_lines){
        item.setChecked(!item.isChecked());
        wrap = item.isChecked();
        PrefUtils.set(PrefUtils.CODE_WRAP, wrap);
        if(ViewerActivity.ViewerType.RepoFile.equals(mPresenter.getViewerType())){
            loadCode(mPresenter.getDownloadSource(), mPresenter.getExtension());
        } else if(ViewerActivity.ViewerType.DiffFile.equals(mPresenter.getViewerType())){
            loadDiffFile(mPresenter.getCommitFile().getPatch());
        }
        return true;
    } else if(item.getItemId() == R.id.action_refresh){
        refresh();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:19,代码来源:ViewerFragment.java

示例3: handleSortOrderMenuItem

import android.view.MenuItem; //导入方法依赖的package包/类
private boolean handleSortOrderMenuItem(@NonNull MenuItem item) {
    String sortOrder = null;
    switch (item.getItemId()) {
        case R.id.action_sort_order_artist:
            sortOrder = ArtistSortOrder.ARTIST_A_Z;
            break;
        case R.id.action_sort_order_artist_desc:
            sortOrder = ArtistSortOrder.ARTIST_Z_A;
            break;
    }
    if (sortOrder != null) {
        item.setChecked(true);
        setSaveSortOrder(sortOrder);
    }
    return true;
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:17,代码来源:ArtistsFragment.java

示例4: onOptionsItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

/*        if (id == R.id.action_force_refresh) {
            updatePoems(null);
            return true;
        } else */
        if (id == R.id.action_mark_read) {
            item.setChecked(!item.isChecked());
            presenter.optionMarkRead(item.isChecked());
        } else if (id == R.id.action_reset_read) {
            showConfirmClearReadDialog();
        } else if (id == R.id.action_notify_new) {
            item.setChecked(!item.isChecked());
            presenter.optionNotifyNew(item.isChecked());
            trackEvent("notificationOption", item.isChecked() ? "yes" : "no", null);
        } else if (id == R.id.action_long_press){
            item.setChecked(!item.isChecked());
            presenter.optionLongPress(item.isChecked());
        } else if (id == R.id.action_stats) {
            presenter.optionStats();
        }

        return super.onOptionsItemSelected(item);
    }
 
开发者ID:PaulKlinger,项目名称:Sprog-App,代码行数:27,代码来源:MainActivity.java

示例5: onOptionsItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Pref pref = Pref.getInstance(this);
    int id = item.getItemId();
    if (id == R.id.show_hidden_files_menu) {
        item.setChecked(!item.isChecked());
        pref.setShowHiddenFiles(item.isChecked());
    } else if (id == R.id.sort_by_name_menu) {
        item.setChecked(true);
        pref.setFileSortType(FileListSorter.SORT_NAME);
    } else if (id == R.id.sort_by_datetime_menu) {
        item.setChecked(true);
        pref.setFileSortType(FileListSorter.SORT_DATE);
    } else if (id == R.id.sort_by_size_menu) {
        item.setChecked(true);
        pref.setFileSortType(FileListSorter.SORT_SIZE);
    } else if (id == R.id.sort_by_type_menu) {
        item.setChecked(true);
        pref.setFileSortType(FileListSorter.SORT_TYPE);
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:FileExplorerActivity.java

示例6: selectNavigation

import android.view.MenuItem; //导入方法依赖的package包/类
public void selectNavigation(MenuItem menuItem) {
    mSelectedAccountId = mAccounts.get(0).id();
    mSelectedNavigationPosition = menuItem.getOrder();
    setTitle(menuItem.getTitle());
    menuItem.setChecked(true);
    mDrawerLayout.closeDrawers();
}
 
开发者ID:mecid,项目名称:robird-reborn,代码行数:8,代码来源:HomeActivity.java

示例7: onOptionsItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.menu_slow) {
        sAnimatorScale = item.isChecked() ? 1 : 5;
        item.setChecked(!item.isChecked());
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:9,代码来源:ActivityAnimations.java

示例8: onOptionsItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
  case R.id.default_options:
    AlarmOptions options = new AlarmOptions();
    Bundle b = new Bundle();
    b.putLong(AlarmNotificationService.ALARM_ID, DbUtil.Settings.DEFAULTS_ID);
    options.setArguments(b);
    options.show(getFragmentManager(), "default_alarm_options");
    return true;

  case R.id.display_notification:
    boolean new_val = !item.isChecked();
    item.setChecked(new_val);
    PreferenceManager.getDefaultSharedPreferences(this)
      .edit()
      .putBoolean(AlarmNotificationService.DISPLAY_NOTIFICATION, new_val)
      .commit();
    AlarmNotificationService.refreshNotificationBar(this);
    return true;

  case R.id.delete_all:
    new DeleteAllConfirmation()
      .show(getFragmentManager(), "confirm_delete_all");

    return true;
  default:
    return super.onOptionsItemSelected(item);
  }
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:31,代码来源:AlarmClockActivity.java

示例9: darkClicked

import android.view.MenuItem; //导入方法依赖的package包/类
private void darkClicked(MenuItem item)
{
    theme = DARK;
    item.setChecked(true);

    if (Build.VERSION.SDK_INT != VERSION_M)
        recreate();
}
 
开发者ID:billthefarmer,项目名称:editor,代码行数:9,代码来源:Editor.java

示例10: onOptionsItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    switch (id){
        // TODO replace the duplicate code with function / classes
        case R.id.menu_sort_recent:
            if (! item.isChecked()) {
                // call the sort function
                item.setChecked(true);
            }
            break;
        case R.id.menu_sort_oldest:
            if (! item.isChecked()) {
                // call the sort function
                item.setChecked(true);
            }
            break;
        case R.id.menu_sort_trending:
            if (! item.isChecked()) {
                // call the sort function
                item.setChecked(true);
            }
            break;
    }

    return super.onOptionsItemSelected(item);
}
 
开发者ID:mtuopensource,项目名称:TechChat,代码行数:31,代码来源:ThreadsActivity.java

示例11: handleSortOrderMenuItem

import android.view.MenuItem; //导入方法依赖的package包/类
private boolean handleSortOrderMenuItem(@NonNull MenuItem item) {
    String sortOrder = null;
    switch (item.getItemId()) {
        case R.id.action_sort_order_album:
            sortOrder = SongSortOrder.SONG_ALBUM;
            break;
        case R.id.action_sort_order_title:
            sortOrder = SongSortOrder.SONG_A_Z;
            break;
        case R.id.action_sort_order_title_desc:
            sortOrder = SongSortOrder.SONG_Z_A;
            break;
        case R.id.action_sort_order_artist:
            sortOrder = SongSortOrder.SONG_ARTIST;
            break;
        case R.id.action_sort_order_year:
            sortOrder = SongSortOrder.SONG_YEAR;
            break;
        case R.id.action_sort_order_duration:
            sortOrder = SongSortOrder.SONG_DURATION;
            break;
        case R.id.action_sort_order_date:
            sortOrder = SongSortOrder.SONG_DATE;
            break;
    }
    if (sortOrder != null) {
        item.setChecked(true);
        setSaveSortOrder(sortOrder);
    }
    return true;
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:32,代码来源:SongsFragment.java

示例12: wrapClicked

import android.view.MenuItem; //导入方法依赖的package包/类
private void wrapClicked(MenuItem item)
{
    wrap = !wrap;
    item.setChecked(wrap);

    if (Build.VERSION.SDK_INT != VERSION_M)
        recreate();
}
 
开发者ID:billthefarmer,项目名称:editor,代码行数:9,代码来源:Editor.java

示例13: onDarkClick

import android.view.MenuItem; //导入方法依赖的package包/类
private boolean onDarkClick(MenuItem item)
{
    dark = !dark;
    item.setChecked(dark);
    if (Build.VERSION.SDK_INT != VERSION_M)
        recreate();

    return true;
}
 
开发者ID:billthefarmer,项目名称:crossword,代码行数:10,代码来源:Main.java

示例14: setActiveTab

import android.view.MenuItem; //导入方法依赖的package包/类
@ReactProp(name = "activeTab", defaultInt = 0)
public void setActiveTab(RNBottomNavigation view, int activeTab) {
    Menu menu = view.getMenu();

    for (int i = 0; i < menu.size(); i++) {
        MenuItem menuItem = menu.getItem(i);
        if (i == activeTab) {
            menuItem.setChecked(true);
        } else {
            menuItem.setChecked(false);
        }
    }
}
 
开发者ID:timomeh,项目名称:react-native-android-bottom-navigation,代码行数:14,代码来源:RNBottomNavigationManager.java

示例15: onPageSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onPageSelected(int position) {
    if (prevSelection != null)
        prevSelection.setChecked(false);
    MenuItem thisMenu = bottomTabs.getMenu().getItem(position);
    thisMenu.setChecked(true);
    prevSelection = thisMenu;
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:9,代码来源:MainActivity.java


注:本文中的android.view.MenuItem.setChecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。