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


Java MenuItem.setCheckable方法代码示例

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


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

示例1: appendFragments

import android.view.MenuItem; //导入方法依赖的package包/类
private void appendFragments(boolean setShortcuts) {
    sActualFragments.clear();
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : sFragments) {
        Fragment fragment = navigationFragment.mFragment;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                Utils.DONATED
                        && Prefs.getBoolean("section_icons", true, this)
                        && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
                        R.drawable.ic_blank);

        if (fragment == null) {
            lastSubMenu = menu.addSubMenu(id);
            sActualFragments.put(id, null);
        } else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled",
                true, this)) {
            MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) :
                    lastSubMenu.add(0, id, 0, id);
            menuItem.setIcon(drawable);
            menuItem.setCheckable(true);
            if (mSelection != 0) {
                mNavigationView.setCheckedItem(mSelection);
            }
            sActualFragments.put(id, fragment);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:36,代码来源:NavigationActivity.java

示例2: appendFragments

import android.view.MenuItem; //导入方法依赖的package包/类
private void appendFragments(boolean setShortcuts) {
    sActualFragments.clear();
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : sFragments) {
        Fragment fragment = navigationFragment.mFragment;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                Utils.DONATED
                        && Prefs.getBoolean("section_icons", false, this)
                        && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
                        R.drawable.ic_blank);

        if (fragment == null) {
            lastSubMenu = menu.addSubMenu(id);
            sActualFragments.put(id, null);
        } else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled",
                true, this)) {
            MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) :
                    lastSubMenu.add(0, id, 0, id);
            menuItem.setIcon(drawable);
            menuItem.setCheckable(true);
            if (mSelection != 0) {
                mNavigationView.setCheckedItem(mSelection);
            }
            sActualFragments.put(id, fragment);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:36,代码来源:NavigationActivity.java

示例3: selectFontSize

import android.view.MenuItem; //导入方法依赖的package包/类
private void selectFontSize() {
    final int defsize = webView.getSettings().getDefaultFontSize();
    int minsize = webView.getSettings().getMinimumFontSize();
    final float scale = getResources().getDisplayMetrics().density;


   // Log.d("READER", "def " + defsize + " " + scale);
    final PopupMenu sizemenu = new PopupMenu(this, findViewById(R.id.zoom_button));
    for (int size=minsize; size<=36; size+=2) {
        final int s = size;

        MenuItem mi = sizemenu.getMenu().add(" "+size);
        mi.setCheckable(true);
        mi.setChecked(size==defsize);

        mi.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem menuItem) {
                Log.d("READER", "def " + (defsize-s));
                int scrolloffset = (int)(-webView.getScrollY()*(defsize - s)/scale/2.7);
                Log.d("READER", "scrollby " + scrolloffset);

                setFontSize(s);

                //attempt to adjust the scroll to keep the same text position.
                //  needs much work
                webView.scrollBy(0, scrolloffset);
                sizemenu.dismiss();
                return true;
            }
        });
    }
    sizemenu.show();


}
 
开发者ID:quaap,项目名称:BookyMcBookface,代码行数:37,代码来源:ReaderActivity.java

示例4: onNavigationItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(final MenuItem menuItem) {
    Menu menu = navigationView.getMenu();
    for (int i = 0; i < menu.size(); i++) {
        MenuItem mi = menu.getItem(i);
        if (!(mi.getItemId() == menuItem.getItemId())) {
            mi.setCheckable(false);
        }
    }
    menuItem.setCheckable(true);
    if (menuItem.getTitle().equals(getResources().getString(R.string.logout))) {
        menuItem.setChecked(false);
    } else {
        menuItem.setChecked(true);
    }
    mNavItemId = menuItem.getItemId();

    // allow some time after closing the drawer before performing real navigation
    // so the user can see what is happening
    drawerLayout.closeDrawer(GravityCompat.START);
    drawerActionHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            navigate(menuItem.getItemId());
        }
    }, DRAWER_CLOSE_DELAY_MS);
    return true;
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:29,代码来源:PublisherActivity.java

示例5: populateContextMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void populateContextMenu(ContextMenu menu, AdapterView.AdapterContextMenuInfo acmi, int num)
{
    try
    {
        if (readWriteAdapter)
        {
            menu.add(0, R.id.fman_action_refresh, 0, R.string.fman_refresh_title);
            menu.add(0, R.id.fman_action_create_folder, 0, R.string.fman_create_folder_title);
            if (num > 0)
            {
                menu.add(0, R.id.fman_action_rename, 0, R.string.fman_rename_title);
                menu.add(0, R.id.fman_action_delete, 0, R.string.fman_delete_title);
            }
        }
        MenuItem activeSort = null;
        menu.add(0, R.id.fman_action_sort_by_name, 0, R.string.fman_sort_by_name);
        if ((mode & MODE_SORTING) == SORT_NAME)
        {
            activeSort = menu.findItem(R.id.fman_action_sort_by_name);
        }
        menu.add(0, R.id.fman_action_sort_by_ext, 0, R.string.fman_sort_by_ext);
        if ((mode & MODE_SORTING) == SORT_EXT)
        {
            activeSort = menu.findItem(R.id.fman_action_sort_by_ext);
        }
        menu.add(0, R.id.fman_action_sort_by_size, 0, R.string.fman_sort_by_size);
        if ((mode & MODE_SORTING) == SORT_SIZE)
        {
            activeSort = menu.findItem(R.id.fman_action_sort_by_size);
        }
        menu.add(0, R.id.fman_action_sort_by_date, 0, R.string.fman_sort_by_date);
        if ((mode & MODE_SORTING) == SORT_DATE)
        {
            activeSort = menu.findItem(R.id.fman_action_sort_by_date);
        }
        if (activeSort != null)
        {
            activeSort.setCheckable(true);
            activeSort.setChecked(true);
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:48,代码来源:AdapterBaseImpl.java


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