Menu setGroupCheckable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Menu setGroupCheckable method.

This code example shows how to use the following methods:add, setGroupCheckable
     
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) {
               
        SubMenu subMenuFile = menu.addSubMenu("Color");
        subMenuFile.add(COLOR_MENU_GROUP, RED, Menu.NONE, "Red");
        subMenuFile.add(COLOR_MENU_GROUP, GREEN, Menu.NONE, "Green");
        subMenuFile.add(COLOR_MENU_GROUP, BLUE, Menu.NONE, "Blue");
        subMenuFile.setGroupCheckable(COLOR_MENU_GROUP, true, false);
         
        SubMenu subMenuEdit = menu.addSubMenu("Font Style");
        subMenuEdit.add(FONT_MENU_GROUP, REGULAR, Menu.NONE, "Regular")
            .setChecked(true);
        subMenuEdit.add(FONT_MENU_GROUP, BOLD, Menu.NONE, "Bold");
        subMenuEdit.add(FONT_MENU_GROUP, ITALIC, Menu.NONE, "Italic");
        subMenuEdit.setGroupCheckable(FONT_MENU_GROUP, true, true);
         
        menu.add(Menu.NONE, HELP, Menu.NONE, "Help");
         
        return super.onCreateOptionsMenu(menu);
6
CodeRank
This code example shows how to use the following methods:add, setGroupCheckable
		subMenu3.add(1, Menu.NONE, Menu.NONE, "Opzione 1");
		subMenu3.add(1, Menu.NONE, Menu.NONE, "Opzione 2");
		subMenu3.add(1, Menu.NONE, Menu.NONE, "Opzione 3");
		subMenu3.setGroupCheckable(1, true, false);
		SubMenu subMenu4 = menu.addSubMenu("Tipo radio");
		subMenu4.add(2, Menu.NONE, Menu.NONE, "Opzione 1");
		subMenu4.add(2, Menu.NONE, Menu.NONE, "Opzione 2");
		subMenu4.add(2, Menu.NONE, Menu.NONE, "Opzione 3");
		subMenu4.setGroupCheckable(2, true, true);
		return true; 
	} 
 
	/* 
	 * (non-Javadoc) 
	 *  
	 * @see android.app.Activity#onBackPressed() 
	 */ 
	@Override 
	public void onBackPressed() { 
		showDialog(DIALOG_MSG_ID);
5
CodeRank
This code example shows how to use the following methods:add, setGroupCheckable
 
	@Override 
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present. 
		SubMenu subMenu = menu.addSubMenu("Change Background");
        subMenu.add(1, 1, 0, "Green").setChecked(true);
        subMenu.add(1, 2, 0, "Red");
        subMenu.add(1, 3, 0, "Blue");
        subMenu.add(1, 4, 0, "Yellow");
        subMenu.add(1, 5, 0, "Grey");
        subMenu.add(1, 6, 0, "Pink");
        subMenu.add(1, 7, 0, "Black");
        subMenu.add(1, 8, 0, "White");
        subMenu.setGroupCheckable(1, true, true);
		return true; 
	} 
	 
	public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case 1: 
5
CodeRank
This code example shows how to use the following methods:add, setGroupCheckable
 
	@Override 
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present. 
		 SubMenu subMenu = menu.addSubMenu("Change Background");
	        subMenu.add(1, 1, 0, "Green").setChecked(true);
	        subMenu.add(1, 2, 0, "Red");
	        subMenu.add(1, 3, 0, "Blue");
	        subMenu.add(1, 4, 0, "Yellow");
	        subMenu.add(1, 5, 0, "Grey");
	        subMenu.add(1, 6, 0, "Pink");
	        subMenu.add(1, 7, 0, "Black");
	        subMenu.add(1, 8, 0, "White");
	        subMenu.setGroupCheckable(1, true, true);
		return true; 
	} 
	 
	public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case 1: 
5
CodeRank
This code example shows how to use the following methods:add, setGroupCheckable
	}}); 
}	        
     
    public boolean onCreateOptionsMenu(Menu menu) {
        SubMenu subMenu = menu.addSubMenu("Change Background");
        subMenu.add(1, 1, 0, "Green").setChecked(true);
        subMenu.add(1, 2, 0, "Red");
        subMenu.add(1, 3, 0, "Blue");
        subMenu.add(1, 4, 0, "Yellow");
        subMenu.add(1, 5, 0, "Grey");
        subMenu.add(1, 6, 0, "Pink");
        subMenu.add(1, 7, 0, "Black");
        subMenu.add(1, 8, 0, "White");
        subMenu.setGroupCheckable(1, true, true);
        return true; 
    } 
     
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case 1: 
5
CodeRank
This code example shows how to use the following methods:add, addSubMenu, setGroupCheckable, getItem, setHeaderTitle
      subPreview.add(1,VIEW_MODE_CANNY,0,"Canny edges");
      subPreview.setGroupCheckable(1, true, true);
       
      SubMenu subCompression = menu.addSubMenu("Compression");
//      subCompression.add(2,IMAGE_TRANSPORT_COMPRESSION_NONE,0,"None"); 
      subCompression.add(2,IMAGE_TRANSPORT_COMPRESSION_PNG,0,"Png");
       
      SubMenu subCompressionRate = subCompression.addSubMenu(2,IMAGE_TRANSPORT_COMPRESSION_JPEG,0,"Jpeg");
      subCompression.setGroupCheckable(2, true, true);
      subCompressionRate.setHeaderTitle("Compression quality");
      subCompressionRate.getItem().setChecked(true);
      subCompressionRate.add(3,50,0,"50");
      subCompressionRate.add(3,60,0,"60");
      subCompressionRate.add(3,70,0,"70");
      subCompressionRate.add(3,80,0,"80").setChecked(true);
      subCompressionRate.add(3,90,0,"90");
      subCompressionRate.add(3,100,0,"100");
      subCompressionRate.setGroupCheckable(3, true, true);
 
      return true; 

4
CodeRank
This code example shows how to use the following methods:add, findItem, setGroupCheckable, setGroupEnabled
		 
		{ 
			int groupNum = 20;
			SubMenu sync = menu.addSubMenu(Menu.NONE, groupNum, 20, "Auto Refresh"); //getItem().
			//sync.setIcon(android.R.drawable.stat_notify_sync); 
			sync.add(groupNum, 0, 0, "On Application Startup");
			sync.add(groupNum, 30, 2, "30 Minutes");
			sync.add(groupNum, 60, 3, "Hourly");
			sync.add(groupNum, 60 * 2, 4, "2 Hours");
			sync.add(groupNum, 60 * 3, 5, "3 Hours");
			sync.add(groupNum, 60 * 4, 6, "4 Hours");
			sync.add(groupNum, 60 * 6, 7, "6 Hours");
			sync.add(groupNum, 60 * 8, 8, "8 Hours");
			sync.add(groupNum, 60 * 12, 9, "12 Hours");
			sync.add(groupNum, 60 * 24, 10, "Daily");
			sync.add(groupNum, 60 * 24 * 2, 11, "2 Days");
			sync.add(groupNum, 60 * 24 * 4, 12, "4 Days");
			sync.add(groupNum, 60 * 24 * 7, 13, "Weekly");
			int syncInterval = mSharedPreferences.contains("sync") ? mSharedPreferences.getInt("sync",300) : 300;
			sync.setGroupCheckable(groupNum, true, true);

-4
CodeRank
setGroupCheckable Method Overview
Control whether a particular group of items can show a check mark.
See Code Examples for other Android Menu Methods: