BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-04-2008, 07:25 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone India
Posts: 39
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone India
Posts: 39
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm glad to read this. No problem.
Offline  
Old 09-08-2008, 07:22 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Oct 2007
Model: 7100i
PIN: N/A
Carrier: Dont know
Posts: 195
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone India
Posts: 39
Post Thanks: 0
Thanked 0 Times in 0 Posts
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





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