BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-21-2010, 10:51 PM   #1 (permalink)
New Member
 
Join Date: Oct 2010
Model: 9650
PIN: N/A
Carrier: Developer
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default The question for DIRECTION !

Please Login to Remove!

Hi all,
I have a sample for DIRECTION.
The first, i declare two objects for display on BlackBerry Screen.
private Screen _secondaryScreen;
private MainScreen mianScreen;
I use transiton to switch between two screen.
I want mainScreen always display on LANDSCAPE mode (Horizontal) by use
Ui.getUiEngineInstance().setAcceptableDirections(D isplay.DIRECTION_EAST), and _secondaryScreen always display on PORTRAIT mode (Vertical) by use
Ui.getUiEngineInstance().setAcceptableDirections(D isplay.DIRECTION_NORTH).
But both mianScreen and _secondaryScreen always display on LANDSCAPE mode. I don't know why. I Hope you can help me, thank you very much !

this is my code.

Code:
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.decor.*;
import net.rim.device.api.system.Display;

public class ScreenTransitionSample extends UiApplication implements
FieldChangeListener 
{
	private ButtonField buttonField1;
	private ButtonField buttonField2;
	private Screen _secondaryScreen;
	private MainScreen mianScreen;
	//private Runnable _popRunnable;
	public static void main(String[] args) 
	{
		ScreenTransitionSample theApp = new ScreenTransitionSample ();
		theApp.enterEventDispatcher();
	}
	public ScreenTransitionSample () 
	{
		_secondaryScreen = new FullScreen();
		_secondaryScreen.setBackground(BackgroundFactory.createSolidBackground(Color.LIGHTBLUE) );
		buttonField1 = new ButtonField("Transition To MainScreenn",ButtonField.CONSUME_CLICK);
		buttonField1.setChangeListener(this);
		_secondaryScreen.add(buttonField1);
		
		TransitionContext transition = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
		transition.setIntAttribute(TransitionContext.ATTR_DURATION, 1000);
		transition.setIntAttribute(TransitionContext.ATTR_DIRECTION,TransitionContext.DIRECTION_RIGHT);
		transition.setIntAttribute(TransitionContext.ATTR_STYLE,TransitionContext.STYLE_PUSH);
		UiEngineInstance engine = Ui.getUiEngineInstance();
		engine.setTransition(null, _secondaryScreen, UiEngineInstance.TRIGGER_PUSH,transition);
		transition = new TransitionContext(TransitionContext.TRANSITION_FADE);
		transition.setIntAttribute(TransitionContext.ATTR_DURATION, 1000);
		transition.setIntAttribute(TransitionContext.ATTR_KIND,TransitionContext.KIND_OUT);
		engine.setTransition(_secondaryScreen, null, UiEngineInstance.TRIGGER_POP,transition);
		mianScreen = new MainScreen();
		mianScreen.setTitle("Screen Transition Sample");
		buttonField2 = new ButtonField("Transition To SecondaryScreen",ButtonField.CONSUME_CLICK) ;
		buttonField2.setChangeListener(this);
		mianScreen.add(buttonField2);
			
		int direction = Display.DIRECTION_EAST;
		Ui.getUiEngineInstance().setAcceptableDirections(direction);
                pushScreen(mianScreen);
	}
	public void fieldChanged(Field field, int context) //overide
	{
				
		if(field == buttonField1)//Transition To MainScreen
		{
			popScreen(_secondaryScreen);
			int direction = Display.DIRECTION_EAST;
			Ui.getUiEngineInstance().setAcceptableDirections(direction);
			pushScreen(mianScreen);
		}
		else if(field == buttonField2) //Transition To SecondaryScreen
		{
			popScreen(mianScreen);
			int direction = Display.DIRECTION_NORTH;
			Ui.getUiEngineInstance().setAcceptableDirections(direction);
			pushScreen(_secondaryScreen);
		}
	}
}

Last edited by levanphong7887 : 10-21-2010 at 11:30 PM.
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.