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


Java SubMenu.setGroupCheckable方法代码示例

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


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

示例1: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
@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_ignore_setting, menu);
    SubMenu subMenu = menu.addSubMenu(GROUP_ID, BASE_ID, 0, "排序");
    subMenu.setIcon(R.drawable.ic_sort_white_24dp);
    subMenu.add(GROUP_ID + 1, BASE_ID + 1, 0, "应用名");
    subMenu.add(GROUP_ID + 1, BASE_ID + 2, 1, "选中");
    subMenu.add(GROUP_ID + 2, BASE_ID + 3, 2, "降序")
           .setCheckable(true)
           .setChecked(true);
    subMenu.setGroupCheckable(GROUP_ID + 1, true, true);
    mMenuItem = menu.findItem(R.id.allcheck);
    ActionItemBadge.update(this, mMenuItem, FontAwesome.Icon.faw_check,
            ActionItemBadge.BadgeStyles.DARK_GREY, 0);
    return true;
}
 
开发者ID:towavephone,项目名称:MemoryCleaner,代码行数:17,代码来源:IgnoreSetting.java

示例2: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
@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_memory_clean, menu);
    SubMenu subMenu = menu.addSubMenu(GROUP_ID, BASE_ID, 0, "排序");
    subMenu.setIcon(R.drawable.ic_sort_white_24dp);
    subMenu.add(GROUP_ID + 1, BASE_ID + 1, 0, "应用名");
    subMenu.add(GROUP_ID + 1, BASE_ID + 2, 1, "大小");
    subMenu.add(GROUP_ID + 1, BASE_ID + 3, 2, "选中");
    subMenu.add(GROUP_ID + 2, BASE_ID + 4, 3, "降序")
           .setCheckable(true)
           .setChecked(true);
    subMenu.setGroupCheckable(GROUP_ID + 1, true, true);
    mMenuItem = menu.findItem(R.id.allcheck);
    ActionItemBadge.update(this, mMenuItem, FontAwesome.Icon.faw_check,
            ActionItemBadge.BadgeStyles.DARK_GREY, 0);
    return true;
}
 
开发者ID:towavephone,项目名称:MemoryCleaner,代码行数:18,代码来源:MemoryClean.java

示例3: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.attendance_menu, menu);

    SubMenu branches = menu.addSubMenu(12, 100, 0, "Branch");
    branches.setHeaderTitle(Html.fromHtml("<font color = '#03A9F4'>Select Branch</font>"));
    branches.setGroupCheckable(1, true, true);

    String division = "<font color = '#757575'>" + divisionNames.get(0) + "</font>";
    String branch = " " + branchNames.get(0);

    currentBranchItem = branches.add(1, 0, 0, Html.fromHtml(division + branch)).setCheckable(true).setChecked(true);
    for (int i = 1; i < branchNames.size(); i++) {
        division = "<font color = '#757575'>" + divisionNames.get(i) + "</font>";
        branch = " " + branchNames.get(i);
        branches.add(1, i, i, Html.fromHtml(division + branch)).setCheckable(true).setChecked(false);
    }

    return true;
}
 
开发者ID:CoepPortal,项目名称:PortalApp,代码行数:21,代码来源:AttendanceActivity.java

示例4: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.subject_details_menu, menu);

    SubMenu branches = menu.addSubMenu(12, 100, 0, "Branch");
    branches.setHeaderTitle(Html.fromHtml("<font color = '#03A9F4'>Select Branch</font>"));
    branches.setGroupCheckable(1, true, true);

    String division = "<font color = '#757575'>" + divisionNames.get(0) + "</font>";
    String branch = " " + branchNames.get(0);

    currentBranchItem = branches.add(1, 0, 0, Html.fromHtml(division + branch)).setCheckable(true).setChecked(true);
    for (int i = 1; i < branchNames.size(); i++) {
        division = "<font color = '#757575'>" + divisionNames.get(i) + "</font>";
        branch = " " + branchNames.get(i);
        branches.add(1, i, i, Html.fromHtml(division + branch)).setCheckable(true).setChecked(false);
    }

    return true;
}
 
开发者ID:CoepPortal,项目名称:PortalApp,代码行数:21,代码来源:SubjectDetailsActivity.java

示例5: setupNavMenu

import android.view.SubMenu; //导入方法依赖的package包/类
/**
 * Setups the navigation drawer's menu to include the given collection of subreddits.
 * The subreddit portion of this menu is rebuilt each time.
 *
 * @param subreddits the collection of subreddits to add to the menu
 */
private void setupNavMenu(Collection<String> subreddits) {
    NavigationView mNavView = (NavigationView) findViewById(R.id.nav_view);
    if (subreddits.isEmpty() || mNavView == null) return;
    Menu menu = mNavView.getMenu();
    menu.removeGroup(SUBREDDIT_MENU_GRP);
    SubMenu subMenu = menu.addSubMenu(SUBREDDIT_MENU_GRP, Menu.NONE, Menu.NONE, "Subreddit");
    for (String subreddit : subreddits) {
        subMenu.add(SUBREDDIT_MENU_GRP, Menu.NONE, Menu.NONE, subreddit);
    }
    subMenu.setGroupCheckable(SUBREDDIT_MENU_GRP, true, true);
    mNavView.setNavigationItemSelectedListener(item -> {
        selectNavItem(item);
        return true;
    });
}
 
开发者ID:JotraN,项目名称:Reader,代码行数:22,代码来源:MainActivity.java

示例6: refresh

import android.view.SubMenu; //导入方法依赖的package包/类
public void refresh(boolean loadFromFile)
{
    //Chargement de la liste des groupes
    if (loadFromFile) {
        groups = GroupManager.readGroups(this);
    }

    if (groups.isEmpty()) {
        this.startActivity(new Intent(this, AddGroupActivity.class));
        finish();
        return;
    }

    SubMenu subMenu = navigationView.getMenu().getItem(0).getSubMenu();
    subMenu.clear();

    for (int i = 0; i < groups.size(); i++) {
        Group g = groups.get(i);
        subMenu.add(DRAWER_GROUP_ID, i, Menu.FIRST, g.name);
    }
    subMenu.setGroupCheckable(DRAWER_GROUP_ID, true, true);

    navigationView.invalidate();

    Group lastSelectedGroup = GroupManager.getSelectedGroup(this);
    //Si on a un SELECT_LAST_ONE de défini
    if (getIntent().getBooleanExtra(INTENT_SELECT_LAST_ONE, false))
    {
        selectGroup(groups.get(groups.size()-1));
    }
    else if (lastSelectedGroup != null && groups.contains(lastSelectedGroup))
    {
        selectGroup(lastSelectedGroup);
    }
    else
    {
        selectGroup(groups.get(0));
    }
}
 
开发者ID:natinusala,项目名称:openedt,代码行数:40,代码来源:MainActivity.java

示例7: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
/**
 * 创建菜单:
 * ——这也是个回调,当用户按下菜单键的时候就会调用
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) 
{
	//参数:就是要显示的菜单
	this.showToast("这是要显示菜单啊!");
	
	//------------向menu中添加字体大小的子菜单---------------------
	SubMenu fontMenu = menu.addSubMenu("字体大小");
	fontMenu.setIcon(R.drawable.red);//设置菜单的图标
	fontMenu.setHeaderIcon(R.drawable.red);//设置菜单头的图标
	fontMenu.setHeaderTitle("选择字体大小"); //设置菜单头的标题
	fontMenu.add(0, FONT_10, 0, "10号字体");
	fontMenu.add(0, FONT_12, 0, "12号字体");
	fontMenu.add(0, FONT_14, 0, "14号字体");
	fontMenu.add(0, FONT_16, 0, "16号字体");
	fontMenu.add(0, FONT_18, 0, "18号字体");
	
	//------------向menu中添加普通菜单项---------------------
	MenuItem item = menu.add(0, PLAIN_ITEM, 0, "普通菜单项");
	item.setIcon(R.drawable.red);
	
	//------------向menu中添加文字颜色的子菜单---------------
	SubMenu colorMenu = menu.addSubMenu("字体颜色");
	colorMenu.setIcon(R.drawable.purple); //设置菜单标题
	colorMenu.setHeaderIcon(R.drawable.purple);  //设置菜单头的图标
	colorMenu.setHeaderTitle("选择文字颜色");
	colorMenu.add(0,FONT_RED,0,"红色");
	colorMenu.add(0,FONT_GREEN,0,"绿色");
	colorMenu.add(0,FONT_BLUE,0,"蓝色");	
	
	//-----------单选菜单项--------------------------
	SubMenu genderMenu = menu.addSubMenu("你的性别");
	genderMenu.setHeaderTitle("选择你是男是女");
	genderMenu.add(0, MALE, 0, "男的");
	genderMenu.add(0, FEMALE, 0, "女的");
	//设置这里边的0组菜单项为单选菜单项
	//===参数1:哪组被设置
	//===参数2:是否可选
	//===参数3:true为单选,false为多选
	//===勾选之后界面的变化还要通过消息响应的代码来设置
	genderMenu.setGroupCheckable(0, true, true);

	//-----------多选菜单项--------------------------
	SubMenu favColorMenu = menu.addSubMenu("你喜欢的颜色");
	favColorMenu.setHeaderTitle("选择你喜欢的颜色");
	favColorMenu.add(0, RED, 0, "红色").setCheckable(true);
	favColorMenu.add(0, BLUE, 0, "蓝色").setCheckable(true);
	favColorMenu.add(0, GREEN, 0, "绿色").setCheckable(true);
	
	//-----------启动新的Activity--------------------------
	//===需要配合菜单响应中的item.getIntent()来startActivity()
	MenuItem launcher = menu.add(0, 200, 0,"启动新Activity");
	launcher.setIntent(new Intent(this, V_Clock.class));
	
	return super.onCreateOptionsMenu(menu);
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:61,代码来源:UIMainActivity.java


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