I want to share a problem i have:
Im testing the Menus features, everything went ok, until i get to the context menus items.
When i setChecked(true) the context SubMenus its "gets Checked", but when i open de context SubMenu again, it doesn´t show the checked status. It´s like them reset everytime i open the context SubMenu.
Here is the code, sorry for my bad english.
PS: With common menus and Submenus they work fine, with the context menu works fines, but, with context SUBMENUS is the problem.
Hope you can help me.
Using java Syntax Highlighting
- //CONTEXT MENU
- @Override
- public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo)
- {
- int qCtMenus = 3;
- int qCtsMenus = 10;
- int ctGroupID = 0;
- int ctMenuID = 0;
- int ctSubMenuID = 0;
- String ctSubMenuTxt = "Context SubMenú ";
- String ctCheckTxt = "Checkable ";
- String ctRadioTxt = "Radio ";
- super.onCreateContextMenu(menu, v, menuInfo);
- //CREO XCANTIDAD CONTEXT MENU CON SUBMENU (qCtMenus)
- for (int i =0; i<qCtMenus;i++)
- {
- ctGroupID = i;
- ctMenuID = i;
- SubMenu mct = menu.addSubMenu(ctGroupID, ctMenuID, Menu.NONE, "Context Menú " + ctMenuID);
- //CREO XCANTIDAD DE SUBMENUS CONTEXT (qCtsMenus)
- for (int j =0; j<qCtsMenus;j++)
- {
- ctSubMenuID = j;
- switch(ctGroupID)
- {
- case 0://COMMON_GROUP
- {
- MenuItem sct = mct.add(COMMON_GROUP, ctSubMenuID, Menu.NONE, ctSubMenuTxt + ctSubMenuID );
- break;
- }
- case 1://CHECKED_GROUP
- {
- MenuItem sct = mct.add(CHECKED_GROUP, ctSubMenuID, Menu.NONE, ctCheckTxt + ctSubMenuID ).setCheckable(true);
- break;
- }
- case 2://RADIO_GROUP
- {
- MenuItem sct = mct.add(RADIO_GROUP, ctSubMenuID, Menu.NONE, ctRadioTxt + ctSubMenuID );
- mct.setGroupCheckable(RADIO_GROUP, true, true);
- break;
- }
- }
- }
- }
- }
- //OPCIONES DE SELECCION DE CONTEXT MENU
- @Override
- public boolean onContextItemSelected(MenuItem item)
- {
- switch(item.getGroupId())
- {
- case CHECKED_GROUP:
- {
- //ACA VA EL SWITCH item.getItemID() para saber que hacer con cada boton.
- if(item.isChecked())
- {
- item.setChecked(false);
- }
- else
- {
- item.setChecked(true);
- }
- break;
- }
- case RADIO_GROUP:
- {
- item.setChecked(true);
- break;
- }
- }
- return true;
- }
Parsed in 0.039 seconds, using GeSHi 1.0.8.4

