English 中文(简体)
Blackberry - close splash screen on any key
原标题:

I am trying to adapt a piece of existing code. I am trying to remove a timer on a splash screen and change it to "press any key to continue" type screen. I need some help with the push/popscreen logic and listening for a keystroke on the splash screen. Here is extract from the code.

public class MenuMain_Pca extends UiApplication {
    public static void main(String[] args) {
        MenuMain_Pca myStart = new MenuMain_Pca();
        myStart.enterEventDispatcher();
    }
    public MenuMain_Pca() {
        Screen_Splash_Screen wScreen = new Screen_Splash_Screen();
        this.pushScreen(wScreen);
        this.popScreen(wScreen);
        MenuMain_Pca.this.pushScreen(new HomeScreen());
    }
}

class Screen_Splash_Screen extends MainScreen implements KeyListener {
    public Screen_Splash_Screen() {
        super(DEFAULT_MENU | DEFAULT_CLOSE);
        Bitmap b240 = new Bitmap(240, 163);
        b240 = Bitmap.getBitmapResource("image1.png");
        BitmapField bf = new BitmapField(b240);
        bf.setSpace(Display.getWidth() / 2 - b240.getWidth() / 2, 0);
        add(bf);
    }
    public boolean keyChar(char key, int status, int time) {
        return true;
    }
    public boolean keyDown(int keycode, int time) {
        return true;
    }
    public boolean keyRepeat(int keycode, int time) {
        return true;
    }
    public boolean keyStatus(int keycode, int time) {
        return true;
    }
    public boolean keyUp(int keycode, int time) {
        return true;
    }
}

class HomeScreen extends MainScreen implements FieldChangeListener {
    private ButtonField button1 = null;
    public HomeScreen() {
        super(DEFAULT_MENU | DEFAULT_CLOSE);
        setTitle(new LabelField("label1", LabelField.ELLIPSIS
                | LabelField.USE_ALL_WIDTH));
        int screenWidth = Display.getWidth() * 95 / 100;
        button1 = new ButtonField("Button1");
        button1.setChangeListener(this);
        add(button1);
    }

    public void fieldChanged(Field field, int context) {
        if (field == (Field) button1)
            UiApplication.getUiApplication().pushScreen(new menu1(1));
    }

    // ask user if he really wants to leave...
    public boolean onClose() {
        boolean retval = false;
        String label = "Are you sure you want to Exit now?";
        int response = Dialog.ask(Dialog.D_YES_NO, label, Dialog.YES);
        if (response == Dialog.YES) {
            System.exit(0);
            retval = true;
        }
        return retval;
    }
}
问题回答

Try to use keyDown event in splash screen, like this:

public boolean keyDown(int keycode, int time) {
        getUiEngine().pushScreen(new HomeScreen());
        getUiEngine().popScreen(this);
    return true;
}




相关问题
How to start to create an application GUI using C#?

HI! I am new to C# and plan to use it for my application GUI. I am trying to make my GUI similar to SPSS:http://www.spss.com/images/08/statistics_screens/ez_rfm-big.jpg Is this easy in C#? Is there ...

Automatic height of edit box

My shoes application has three items stacked on top of each other (with a stack, of course), in order: A banner An edit box Two buttons in a flow What I want to do is have the banner stay at it s ...

Search by using the keyboard in a list/grid - algorithm

I need to implement a custom search in a grid and I would like to find some user interface guidelines that explain the standard way to implement it. I mean this kind of search that is initiated by ...

UI And TcpClient Issue in vb.net

I m having some problems with a small ircbot i m writing. Basically I connect to the server using a tcpclient in a seperate class, which also runs on its own thread. I want to display the server text ...

UI Convention: Shortcut key for application exit? [closed]

Is there a convention for the shortcut keys for application exit? Some applications uses Alt+X some others use Ctrl+ X and Ctrl+Q. Applications like FF and IE doesnot assign a shortcut at all. So is ...

热门标签