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 Contributor
Posts: 2
Registered: ‎06-29-2011
My Device: 9300
Accepted Solution

Slide transition problem

Hi! Here is the problem I'm facing with a sample app developed to learn slide transition.
The effect I'd like to achieve is similar to the one used on blackberry os in the home screen: buttons are arranged horizontally at the bottom of the screen and when you slide the trackpad down other buttons are revealed.

 

Leaving out the already solved problem on arranging various ui elements on the screen, I developed a home screen, the screen that you see when you open the sample app, and a second screen, the screen that slides from the lower side of the display.

 

The home screen is completely opaque, while the second screen has a transparent background in the upper area, say 1/3, and a partially transparent for the remaining 2/3 lower area.

 

This is the code that implements and activate the transition from the home screen to the second screen:

 

protected boolean navigationClick(int status, int time) {
	engine = Ui.getUiEngineInstance();
			
	transitionIn = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
	transitionIn.setIntAttribute(TransitionContext.ATTR_DURATION, 400);
	transitionIn.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_UP);
	transitionIn.setIntAttribute(TransitionContext.ATTR_STYLE, TransitionContext.STYLE_OVER);
			
	transitionOut = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
	transitionOut.setIntAttribute(TransitionContext.ATTR_DURATION, 400);
	transitionOut.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_DOWN);
	transitionOut.setIntAttribute(TransitionContext.ATTR_KIND, TransitionContext.KIND_OUT);
	transitionOut.setIntAttribute(TransitionContext.ATTR_STYLE, TransitionContext.STYLE_OVER);
			
	new Runnable() {
		public void run() {
		Screen next = new SecondScreen();
			engine.setTransition(null, next, UiEngineInstance.TRIGGER_PUSH, transitionIn);
			engine.setTransition(next, null, UiEngineInstance.TRIGGER_POP, transitionOut);
			UiApplication.getUiApplication().pushScreen(next);
		}
	}.run();
	
return true;
}

 

 

 

The transition is working as desired, and as expected, when pushing the second screen on top of the home screen: I can see the home screen remaining fixed and the second screen appearing with the slide movement.
The problem arises when popping the second screen to reveal again the home screen: now, instead of having the second screen sliding down, I see the whole display content moving down.

 

I think that the error is in the transitionOut attributes, but I've tried many combinations of values without success.

Code is targetted for API 6.

New Contributor
Posts: 2
Registered: ‎06-29-2011
My Device: 9300

Re: Slide transition problem

Solved...! :Clap:

This is the code that make the effect work correctly!

 

protected boolean navigationClick(int status, int time) {
	engine = Ui.getUiEngineInstance();
			
	transitionIn = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
	transitionIn.setIntAttribute(TransitionContext.ATTR_DURATION, 400);
	transitionIn.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_UP);
	transitionIn.setIntAttribute(TransitionContext.ATTR_STYLE, TransitionContext.STYLE_OVER);
			
	transitionOut = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
	transitionOut.setIntAttribute(TransitionContext.ATTR_DURATION, 400);
	transitionOut.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_DOWN);
	transitionOut.setIntAttribute(TransitionContext.ATTR_KIND, TransitionContext.KIND_OUT);
	transitionOut.setIntAttribute(TransitionContext.ATTR_STYLE, TransitionContext.STYLE_OVER);
			
	UiApplication.getUiApplication().invokeAndWait(new Runnable() {
	public void run() {
		Screen next = new SecondScreen();
		engine.setTransition(_screen, next, UiEngineInstance.TRIGGER_PUSH, transitionIn);
		engine.setTransition(next, _screen, UiEngineInstance.TRIGGER_POP, transitionOut);
		_manager.hideFooter();
	UiApplication.getUiApplication().pushScreen(next);
	}
		});
	return true;
	}