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



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


Mindray V10-4s Ultrasonic Transducer picture

Mindray V10-4s Ultrasonic Transducer

$1650.00



Sonoscape C362 Ultrasound Probe & Transducer picture

Sonoscape C362 Ultrasound Probe & Transducer

$2500.00



1/8NPT Stainless Pressure Transducer Sender Sensor For Oil Air Fuel Gas 150Psi picture

1/8NPT Stainless Pressure Transducer Sender Sensor For Oil Air Fuel Gas 150Psi

$13.98



Phoenix Contact MCR-R/U-V-DC Resistance Position Transducer Lightly Used picture

Phoenix Contact MCR-R/U-V-DC Resistance Position Transducer Lightly Used

$100.00



US Stock 110VAC 60W 40KHz Ultrasonic Cleaning Transducer Cleaner & Driver Board picture

US Stock 110VAC 60W 40KHz Ultrasonic Cleaning Transducer Cleaner & Driver Board

$50.53



NEW Novotechnik TRS-25 Position Transducer picture

NEW Novotechnik TRS-25 Position Transducer

$288.11







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