BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-04-2008, 07:25 AM   #1
alpeshvesuwala
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone India
Posts: 39
Default Remove default 'Close' menu option in MainScreen

Please Login to Remove!

Hello Mates,

I am creating a screen which extends the MainScreen that causes the default 'Close' menu option to be appended to the menu items that I have added.

I don't want that default 'Close' option.

Is there any way of remove/ disabling the 'Close' menu item??

Please help me out..

Thanks,
Alpesh
Offline  
Old 08-04-2008, 07:58 AM   #2
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Default

I had that problem some months ago. Firstly, you must NOT implement the makeMenu method of your main screen like this:
Code:
protected void makeMenu(Menu menu, int instance) {
    super.makeMenu(menu, 0);
  }
.

I had that method like that, and the default close menu item could not be removed. Then I will give you the implementation of the makeMenu in some of my pages that my application shows (I use context menu, but the idea for the menu is the same I think):
Code:
protected void makeMenu(Menu menu, int instance) {
    ContextMenu contextMenu = ContextMenu.getInstance();
    contextMenu.clear();
    contextMenuListener.makeContextMenu(contextMenu);
    menu.deleteAll();
    menu.add(contextMenu);
  }
.

Implementing the makeContextMenu method (method of my own made ContextMenuListener) you can add your own menu items.
Code:
public void makeContextMenu(ContextMenu contextMenu) {
      //...some other menu items
      contextMenu.addItem(MenuItem.separator(32));
      contextMenu.addItem(preferences);
      contextMenu.addItem(MenuItem.separator(45));
      contextMenu.addItem(close);
    }
.

That is my way of doing it !
Offline  
Old 08-04-2008, 08:01 AM   #3
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Default

One more thing. The close menu item looks like this:
Code:
private MenuItem close = new MenuItem("Exit", 50, 10) {
      public void run() {
         //...add whatever you want :)
         System.exit(0);
      }
    };
. Good Luck !
Offline  
Old 08-05-2008, 07:47 AM   #4
alpeshvesuwala
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone India
Posts: 39
Default

Hey mate,

Nice
It works for me.

Code:
        protected  void makeMenu(Menu menu, int instance)
	{
	    ContextMenu contextMenu = ContextMenu.getInstance();
	    contextMenu.setTarget(this);
	    contextMenu.clear();
	    this.makeContextMenu(contextMenu);
	    menu.deleteAll();
	    menu.add(contextMenu);
	}

	public void makeContextMenu(ContextMenu contextMenu) {
		contextMenu.addItem(close);
	}
Thanks a lot,
Alpesh
Offline  
Old 08-05-2008, 07:59 AM   #5
pa4o85
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Default

I'm glad to read this. No problem.
Offline  
Old 09-08-2008, 07:22 AM   #6
BB1364
Thumbs Must Hurt
 
Join Date: Oct 2007
Model: 7100i
PIN: N/A
Carrier: Dont know
Posts: 195
Default

hi

i read your thread and i have the same requirement i.e. to remove the default "Close " menu item. But when i tried out as discussed i am not able to remove the default close menuitem. i tried it like this:


Code:
 protected void makeMenu(Menu menu , int instance) {
        ContextMenu contextMenu = ContextMenu.getInstance();
        contextMenu.setTarget(this);
        contextMenu.clear();
        contextMenuListener.makeContextMenu(contextMenu);
        menu.deleteAll();
        menu.add(contextMenu);
    } 
    
     public void makeContextMenu(ContextMenu contextMenu) {
                contextMenu.addItem(refresh); 
                contextMenu.addItem(configure);
              contextMenu.addItem(logout);
           }

contextMenuListener cannot be found.
Offline  
Old 09-08-2008, 11:45 PM   #7
alpeshvesuwala
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone India
Posts: 39
Default

Hi

I think problem is with,
Quote:
contextMenuListener.makeContextMenu(contextMenu);
You can refine it by extending the MainScreen class and try with,
Code:
this.makeContextMenu(contextMenu);
One more solution to this is,
Remove super.makeMenu(menu, instance); from
Code:
protected void makeMenu(Menu menu, int instance) {
//super.makeMenu(menu, instance); // Do not call 
}
Hope this may help you

Thanks,
alpesh
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


RADSTONE VME BOARD PME 68-31 MOTOROLA 6800 33Mhz AMIGA PPC  Module  card picture

RADSTONE VME BOARD PME 68-31 MOTOROLA 6800 33Mhz AMIGA PPC Module card

$185.00



RADSTONE VME BOARD PME 68-33 MOTOROLA 6800 33Mhz AMIGA PPC picture

RADSTONE VME BOARD PME 68-33 MOTOROLA 6800 33Mhz AMIGA PPC

$185.00



23 WAY MALE

23 WAY MALE "D" PLUG DB23 CONNECTOR FOR COMMODORE AMIGA - RARE

$8.20



RADSTONE VME BOARD PME 68-31 MOTOROLA 6800 33Mhz AMIGA PPC Module card SCSI picture

RADSTONE VME BOARD PME 68-31 MOTOROLA 6800 33Mhz AMIGA PPC Module card SCSI

$185.00



NEW OPTICAL LASER PICKUP HEAD for AMIGA CD 32 SYSTEM CONSOLE picture

NEW OPTICAL LASER PICKUP HEAD for AMIGA CD 32 SYSTEM CONSOLE

$18.50



GGLABS E2R16 PCB - TL866 27C400 Prog Adapter - Read/Write Amiga Kickstart ROMs picture

GGLABS E2R16 PCB - TL866 27C400 Prog Adapter - Read/Write Amiga Kickstart ROMs

$3.97







Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.