除了推屏之外还有其他方法可以进入下一个屏幕吗?

时间:2011-01-20 09:19:21

标签: blackberry java-me

当用户点击ListField时,我想显示另一个屏幕。

但是我的包含ListField的类扩展了MainScreen!

如何推送到另一个屏幕?

除了pushScreen之外还有其他方法可以转到另一个屏幕吗?

1 个答案:

答案 0 :(得分:-1)

OverRide NavigationClick,下面是示例

public boolean navigationClick(int status,int time){
    Field focus = _countries.getLeafFieldWithFocus();
    if(focus instanceof ListField){
        ListField listField = (ListField)focus;
        country = listField.getCallback().get(listField,listField.getSelectedIndex()).toString();//this will return the text clicked from the listfield

    TransitionContext transition = new TransitionContext(TransitionContext.TRANSITION_FADE);
    transition.setIntAttribute(TransitionContext.ATTR_DURATION,500);
    transition.setIntAttribute(TransitionContext.ATTR_DIRECTION,TransitionContext.DIRECTION_DOWN);
    transition.setIntAttribute(TransitionContext.ATTR_STYLE,TransitionContext.STYLE_PUSH);

    UiEngineInstance engine = Ui.getUiEngineInstance();
    engine.setTransition(MyApp.scr,MyScreen._radio,UiEngineInstance.TRIGGER_PUSH,transition);
    MyApp.scr=null;
    UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
    UiApplication.getUiApplication().pushScreen(MyScreen._radio);
    }

    return true;    
}