如何导航回到在黑莓的previous屏幕? [英] How to navigate back to the previous screen in Blackberry?

查看:108
本文介绍了如何导航回到在黑莓的previous屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在黑莓,我可以从一个屏幕转到下一屏幕,但我不能导航回到previous屏幕。 pressing在模拟器中ESC键终止整个应用程序。有没有在模拟器任意键进入previous屏幕或code导航回?如果你知道,请帮助我。

In Blackberry I can navigate from one screen to the next screen, but I can't navigate back to the previous screen. Pressing the escape key in the emulator terminates the entire application. Is there any other key in the emulator to go to the previous screen or any code to navigate back? If you know please help me.

推荐答案

至于安德烈说,有一个显示栈,所以如果你把屏幕没有弹出他们,他们会留在堆栈,因此关闭当前屏幕,previous屏幕就会automattically示出,并且如果不存在$ p $光伏。屏幕上,应用程序将关闭。

As Andrey said, there is a display stack, so if you push screens without popping them, they will stay in stack, so closing current screen, previous screen will be shown automattically, and if there is no prev. screen, application will close.

然而,它并不好持有显示器层叠多个屏幕,这样你就可以实现屏幕内种叠加,手动处理的导航。

However it's not good to hold many screens in display stack, so you can implement kind of stack inside of screens, to handle navigation manually.

有关屏栈的实现摘要屏幕类:

Abstract screen class for screen stack implementation:

public abstract class AScreen extends MainScreen {
    Screen prevScreen = null;

    void openScreen(AScreen nextScreen) {
    	nextScreen.prevScreen = this;
    	UiApplication.getUiApplication().popScreen(this);
    	UiApplication.getUiApplication().pushScreen(nextScreen);
    }

    void openPrevScreen() {
    	UiApplication.getUiApplication().popScreen(this);
    	if (null != prevScreen)
    		UiApplication.getUiApplication().pushScreen(prevScreen);
    }
}

样第一个画面:

public class FirstScreen extends AScreen implements FieldChangeListener {

    ButtonField mButton = null;

    public FirstScreen() {
    	super();
    	mButton = new ButtonField("Go second screen", ButtonField.CONSUME_CLICK);
    	mButton.setChangeListener(this);
    	add(mButton);
    }

    public void fieldChanged(Field field, int context) {
    	if (mButton == field) {
    		openScreen(new SecondScreen());
    	}
    }
}

样品第二个画面:

Sample second screen:

public class SecondScreen extends AScreen implements FieldChangeListener {

    ButtonField mButton = null;

    public SecondScreen() {
    	super();
    	mButton = new ButtonField("Go first screen", ButtonField.CONSUME_CLICK);
    	mButton.setChangeListener(this);
    	add(mButton);
    }

    public void fieldChanged(Field field, int context) {
    	if (mButton == field) {
    		openPrevScreen();
    	}
    }

    public boolean onClose() {
    	openPrevScreen();
    	return true;
    }
}

这篇关于如何导航回到在黑莓的previous屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆