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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
rabiyabasri
Posts: 49
Registered: ‎12-21-2010
My Carrier: software developer

Slide Screen Issue

Hi,

 

This is my code for sliding screen from left to right using ButtonField.

public class MyApp extends UiApplication
{
    MyApp app = this;
   
    public static void main(String[] args)
    {
        MyApp theApp = new MyApp();      
        theApp.enterEventDispatcher();
    }

    public MyApp()
    {       
        // Push a screen onto the UI stack for rendering.
        pushScreen(new MyScreen(app));
    } 
}

public final class MyScreen extends MainScreen implements FieldChangeListener
{   
    Bitmap bmpResized;
   
    MyApp app;
    ButtonField nextButton = new ButtonField("Next Screen", ButtonField.CONSUME_CLICK);
   
    public MyScreen(MyApp app){
        super();
        setTitle("Home Screen");
        this.app = app;
        nextButton.setChangeListener(this);
        add(nextButton);
     } 
    public void fieldChanged(Field field, int context) {
        if (field == nextButton) {
            ContentScreen contentScreen = new ContentScreen(app);
            UiEngineInstance engine = Ui.getUiEngineInstance();
 
            TransitionContext transitionContextPush = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
            transitionContextPush.setIntAttribute(TransitionContext.ATTR_DURATION, 750);
            transitionContextPush.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_LEFT);
 
            TransitionContext transitionContextPop = new TransitionContext(TransitionContext.TRANSITION_SLIDE);
            transitionContextPop.setIntAttribute(TransitionContext.ATTR_DURATION, 750);
            transitionContextPop.setIntAttribute(TransitionContext.ATTR_DIRECTION, TransitionContext.DIRECTION_RIGHT);
            transitionContextPop.setIntAttribute(TransitionContext.ATTR_KIND, TransitionContext.KIND_OUT);
 
            engine.setTransition(null, contentScreen, UiEngineInstance.TRIGGER_PUSH, transitionContextPush);
            engine.setTransition(contentScreen, null, UiEngineInstance.TRIGGER_POP, transitionContextPop);
 
            app.pushScreen(contentScreen);
        }
    }
 
    public boolean onClose(){
        System.exit(0);
        return true;
    }
}
Its working fine, but i want slide the screen when we scroll the screen left and right like in Sencha Touch using Carousel Class. is it possible in blackberry. if possible past the sample code..

 

Thanks

Please use plain text.
Administrator
MSohm
Posts: 13,065
Registered: ‎07-09-2008
My Carrier: Bell

Re: Slide Screen Issue

You could capture a TouchGesture and transtion your screen when the user swipes east or west.  You can read more about touch events here:  http://docs.blackberry.com/en/developers/deliverables/29251/Touch_screen_interaction_models_1222741_...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.