Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
manarS
Posts: 34
Registered: ‎03-12-2012
My Device: blackberry tourch

remove standard events menu items

hola friends,

 

i am wondering, are there any possibility to remove standards menu items?

for instance: close, select, copy...etc

 

actually, i have created number of screens and i noticed all of these screens have ( close and switch application menu items) and i would like to remove them and i don't know how..!

 

anybody have an idea about this issue?

 

Waiting ...

Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Device: BB Bold

Re: remove standard events menu items

Hi,

 

If you override the makeMenu method in your screen, you can get rid of copy /select/close.....but i do not think it will delete switch Application.

 

protected void makeMenu(Menu menu, int instance) {
menu.deleteAll();
menu.add(new MenuItem("Test",100,100) {

public void run() {
// TODO Auto-generated method stub

}
});
}

New Developer
manarS
Posts: 34
Registered: ‎03-12-2012
My Device: blackberry tourch

Re: remove standard events menu items

thanx brother for the fast replay..

 

actually i am using JRE 7 firstly, and i am using MenuItem to create menus .. so deleteAll() method doesnt work with it.. and i doesnt matter i can deal with that.. but i have a big problem with my code

MenuItem constructor takes 3 paramters.. " string. ordinal. and periority" and this error forced me to change the 2nd and last arguments everytime, the error is NullPointerException error.

 

so if i want to run my code, i need 5 or 6 times to get the error and in 7th time finally i works correctly..

 

please try to help me beacuse its my senior project and i dont wont to show my advisors bad work..

 

this is my code..

package com.rim.samples.device.ui;


import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.*;

import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.util.StringProvider;



public class ArabicStoryList extends MainScreen 
{
    private Bitmap _bitmaps;
    private Bitmap _bitmaps2;
 
    public ArabicStoryList() 
    {
    	super(Manager.NO_VERTICAL_SCROLL);
    	 // Set the displayed title of the screen       
        setTitle("arabic story list ");

        _bitmaps = Bitmap.getBitmapResource("chocolate_1.jpg");
        _bitmaps2 = Bitmap.getBitmapResource("lemon_1.jpg");
        HorizontalFieldManager _Hmanager = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.USE_ALL_HEIGHT){
            
            //Override the paint method to draw the background image.
            public void paint(Graphics graphics)
            {
                //Draw the background image and then call paint.
                graphics.drawBitmap(0, 0,950, 400, _bitmaps, 0, 0);
                graphics.drawBitmap(0, 80,950, 400, _bitmaps2, 0, 0);
                super.paint(graphics);
            }            
           
        };
       
     	add(_Hmanager);
     	
     	
      add(new SeparatorField());
    addMenuItem(new Play4MenuItem());
       addMenuItem(new Sort4MenuItem());
      
      add(new SeparatorField());
      addMenuItem(new Options4MenuItem());
      addMenuItem(new Home4MenuItem());
     addMenuItem(new Help4MenuItem());
      
      add(new SeparatorField());
      
    }
    private class Play4MenuItem extends MenuItem
    {
    	public Play4MenuItem()
    	{
    		
    		super(new StringProvider("Play Story"),0x230170, 7);
    	}
    	public void run()
        {
            // pushScreen story screen to open it
    		
    		
         	
         }
    }

    
    private class Sort4MenuItem extends MenuItem
    {
    	public Sort4MenuItem()
    	{
    		super(new StringProvider("Sort Story"),0x230180, 8);
    	}
    	public void run()
        {
            // pushScreen for home screen
         	
         }
    }
    private class Options4MenuItem extends MenuItem
    {
    	public Options4MenuItem()
    	{
    		super(new StringProvider("Options"),0x230190, 9);
    	}
    	public void run()
        {
    		//Dialog.inform("going to option page");
    		// to display screen : open screen from another screen
    		UiApplication.getUiApplication().pushScreen(new OptionPage());
         	
         }
    }
    private class Home4MenuItem extends MenuItem
    {
    	public Home4MenuItem()
    	{
    		super(new StringProvider("Home"),0x230200, 10);
    	}
    	public void run()
        {
    		//Dialog.inform("going to home page");
    		// to display screen : open screen from another screen
    		UiApplication.getUiApplication().pushScreen(new HomePage());
         	
         }
    }
    private class Help4MenuItem extends MenuItem
    {
    	public Help4MenuItem()
    	{
    		
    		super(new StringProvider("Help"),0x230210, 11);
    	}
    	public void run()
        {
    		//Dialog.inform("going to help page");
    		// to display screen : open screen from another screen
    		UiApplication.getUiApplication().pushScreen(new HelpPage());
         	
         }
    }
    }
	





    

 please help :womansad:

New Developer
manarS
Posts: 34
Registered: ‎03-12-2012
My Device: blackberry tourch

Re: remove standard events menu items

thanks brother, i got the error and i corrected it..

 

i dont know how! but i firstly reseted the semulator and then i used the way you gave to me to create menu items.. its really very easy way i dont know why i did that diffecult way by creating private classes rather than creating private variables for the menu items.

 

 

thank you again and i will try your way to remove other un-necessary items. :Yes: