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
Trusted Contributor
Posts: 114
Registered: ‎10-21-2010
My Device: Bold 9650
My Carrier: Develper

Problem with Screen Transition?

Hi all,

 

I have 2 MainScreen Object: screenA and screenB.

The fisrt, I call pushScreen(screenA) and pushScreen(screenB)

I have setTransition for screenB.

I want to see animation transition of screenB thus I call popScreen(screenB) ,pushScreen(screenB).

 

this is my code:

 

MainScreen screenA = ...
MainScreen screenB = ...
main() //main() function
{
   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, screenB, UiEngineInstance.TRIGGER_PUSH , transition);

   pushScreen(screenA);
   pushScreen(screenB);
}

//On screenB have a menu item : "View animation of screenB"
private MenuItem Setting = new MenuItem("View animation of screenB", 100,10) 
{
	public void run() 
	{
	   popScreen(screenB);
           pushScreen(screenB);	
	}
};

 

And it is not any animation when I click "View animation of screenB" menu ???

Please show me what is wrong? many thanks !

 

 

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Problem with Screen Transition?

Hi,

 

I didn't manage to find the problem in the code, but I found a simple example which works.

 

I hope that will help you.

 

E.

 

 

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.*;

public class ScreenTransitionSample extends UiApplication implements FieldChangeListener {
    private Screen _secondaryScreen;
    private Runnable _popRunnable;
    private MainScreen baseScreen;
    
    public static void main(String[] args) {
        ScreenTransitionSample  theApp = new ScreenTransitionSample ();
        theApp.enterEventDispatcher();
    }

    public ScreenTransitionSample () {        
        _secondaryScreen = new MyScreen();        
        //_secondaryScreen.setBackground( BackgroundFactory.createSolidBackground(Color.LIGHTBLUE) );
        
        LabelField labelField = new LabelField("The screen closes automatically in 10 seconds by using a fade transition");
        _secondaryScreen.add(labelField);
        
        TransitionContext transition = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
        transition.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
        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, 500);
        transition.setIntAttribute(TransitionContext.ATTR_KIND, TransitionContext.KIND_OUT);
        engine.setTransition(_secondaryScreen, null, UiEngineInstance.TRIGGER_POP, transition); 
        
        baseScreen = new MainScreen();
        baseScreen.setTitle("Screen Transition Sample");          
        ButtonField buttonField = new ButtonField("View Transition", ButtonField.CONSUME_CLICK) ;
        buttonField.setChangeListener(this);
        baseScreen.add(buttonField);
        
        pushScreen(baseScreen);
        
        _popRunnable = new Runnable() {
            public void run() {
                popScreen(_secondaryScreen);
            }
        };
    }
    
    public void fieldChanged(Field field, int context)
    {
        pushScreen(_secondaryScreen);
        invokeLater(_popRunnable, 10000, false);
        invokeLater(new Runnable() {			
			public void run() {				
				baseScreen.setTitle("Screen Transition Sample!!!!!!!!!!!");
				baseScreen.invalidate();
			}
		}, 2000, false);        
        
    }
    
}

 

 

 

Regular Contributor
Posts: 59
Registered: ‎01-17-2011
My Device: 8520
My Carrier: Vodafone

Re: Problem with Screen Transition?

hello,


you just right this code before push a screen..

 

 transitionContextIn = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
                transitionContextIn.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
                transitionContextIn.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_LEFT);

                transitionContextOut = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
                transitionContextOut.setIntAttribute(TransitionContext.ATTR_DURATION, 500);
                transitionContextOut.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_RIGHT);
                transitionContextOut.setIntAttribute(TransitionContext.ATTR_KIND, TransitionContext.KIND_OUT);

                engine.setTransition(null, screen, UiEngineInstance.TRIGGER_PUSH, transitionContextIn);
                engine.setTransition(screen, null, UiEngineInstance.TRIGGER_POP, transitionContextOut);

 

               pushScreen(screen);

 

 

This code solve your animation problem.

 

 

 

Highlighted
Trusted Contributor
Posts: 114
Registered: ‎10-21-2010
My Device: Bold 9650
My Carrier: Develper

Re: Problem with Screen Transition?

Thanks, but i want to replace screenB by itself and have a animation for this replacement.

And now, i have found solution Smiley Happy