BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-15-2009, 07:17 PM   #1 (permalink)
New Member
 
Join Date: Jul 2009
Model: 7130v
PIN: N/A
Carrier: n/a
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default main menu appears automatically. why?

Please Login to Remove!

I'm using a button in a screen to close a screen and there is a listener which catch that event and opens a new screen.
but the main menu appears automatically for some reason on the new screen in the simulator.
i'm using jde 4.2.1 and 4.5.0
maybe it's only a problem with the simulator? because it happens if i click the track ball when i'm on the button in screen1, but it doesn't happen if i use the enter key on the pc keyboard...

App.java:
Code:
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;

public class App extends UiApplication implements ScreenClosedListener
{
   Screen1 screen1;
   Screen2 screen2;
   
    public static void main(String[] args)
    {
        App  app = new App();
        app.enterEventDispatcher();
    }
    public App()
    {
    	screen1 = new Screen1(this);
        pushScreen(screen1);
    }
    public void notifyScreenClosed(MainScreen screen)
    {
    	// check the event source object
    	if (screen == screen1)
    	{
    		 pushScreen (new Screen2());
    	}
    }
}
Screen.java:
Code:
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;


final class Screen2 extends MainScreen
{

   
    public Screen2()
    {
        super(); 
        setTitle(new LabelField("Screen2"));
    }
    public boolean onClose()
    {
	    return super.onClose();
    }
}
ScreenClosedListener.java:

Code:
import net.rim.device.api.ui.container.MainScreen;

public interface ScreenClosedListener 
{ 
	public void notifyScreenClosed(MainScreen screen);
}
Offline  
Old 07-15-2009, 08:52 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

You need to add the style CONSUME_CLICK to your button.
Offline  
Old 07-16-2009, 04:11 AM   #3 (permalink)
New Member
 
Join Date: Jul 2009
Model: 7130v
PIN: N/A
Carrier: n/a
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, that did it!
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.