开发者

How to enter the blackberry app if I am not using enterEventDispatcher?

开发者 https://www.devze.com 2022-12-10 08:49 出处:网络
My application extends the ui开发者_开发百科.Manager class. Is it possible to enter the app without using the enterEventDispatcher. As it needs me to inherit the Application/UiApplication to do that.

My application extends the ui开发者_开发百科.Manager class. Is it possible to enter the app without using the enterEventDispatcher. As it needs me to inherit the Application/UiApplication to do that.

Is multiple inheritance the solution?

Multiple inheritance is rather not possible in Java. So is it about using interfaces?


You should really inherit App from UiApplication (if it has some UI) or from Application (if it's background app, service).
If you have some Manager extension, place it into Screen extension. Like this:

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;

public class CenterButtonPanelApp extends UiApplication {

    public CenterButtonPanelApp() {
        pushScreen(new Scr());
    }

    public static void main(String[] args) {
        CenterButtonPanelApp app = new CenterButtonPanelApp();
        app.enterEventDispatcher();
    }
}

class Scr extends MainScreen {
    public Scr() {
        CenterButtonPanel centerPanel = new CenterButtonPanel();
        add(centerPanel);
    }
}

class CenterButtonPanel extends HorizontalFieldManager {
    int mWidth = Display.getWidth();

    public CenterButtonPanel() {
        super(FIELD_HCENTER);
    }

    public int getPreferredWidth() {
        return mWidth;
    }

    protected void sublayout(int maxWidth, int maxHeight) {
        super.sublayout(mWidth, maxHeight);
        setExtent(mWidth, maxHeight);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消