0

I'm building a nokia s40 app. I've set this app to be in full screen mode and I notice that when I set this full screen mode, I've lost the native back buttons.

I need to build a back button like the native back button (always on screen, in the bottom right side of the screen). I've tried it with a borderlayout and putting it on the south, but the text from the center container doesn't appears over this...and has transparent background.

If anyone has some sample code, it will be great.

Mun0n
  • 4,438
  • 4
  • 28
  • 46

1 Answers1

1

this code simply located a button in the bottom right side of the screen. it's work well.

public void startApp() {
    Display.init(this);
    Form f = new Form();
    //Create a ComponentGroup for all components except backbutton
    final ComponentGroup cg = new ComponentGroup();
    final Button backButton = new Button("BackButton");
    // add this part to your code
    f.addOrientationListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            Dimension d = new Dimension(Display.getInstance().getDisplayWidth(),  Display.getInstance().getDisplayHeight());
            cg.setPreferredSize(d);
            backButton.setX(Display.getInstance().getDisplayWidth() - backButton.getPreferredW());
        }
    });
    //set CoordinateLayout to f
    f.setLayout(new CoordinateLayout(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight()));


    //Dimension d = new Dimension(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight());
    cg.setPreferredH(Display.getInstance().getDisplayHeight());
    cg.setPreferredW(Display.getInstance().getDisplayWidth());
    cg.setLayout(new BorderLayout());
    cg.addComponent(BorderLayout.NORTH, new Button("NORTH"));
    cg.addComponent(BorderLayout.EAST, new Button("ESET"));
    cg.addComponent(BorderLayout.WEST, new Button("WEST"));
    cg.addComponent(BorderLayout.CENTER, new TextArea("sdsdsd"));

    cg.setX(0);
    cg.setY(0);
    backButton.getStyle().setBgColor(0x2233ff);

    backButton.setX(Display.getInstance().getDisplayWidth() - backButton.getPreferredW());
    backButton.setY(Display.getInstance().getDisplayHeight() - backButton.getPreferredH() - f.getTitleArea().getLayoutHeight());
    f.addComponent(cg);
    f.addComponent(backButton);
    f.show();   
}

you can do like this to any form. if you want back Button is showed in all forms you can write some OOP programming to do this. it works well.

  • Works pefect for one orientation, If you change the orientation the issue is more complex because is neccesary to inform the Layout of the change of the Display's size – Mun0n Aug 21 '13 at 09:26
  • 1
    set a OrientationListener to your form like this: f.addOrientationListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Dimension d = new Dimension(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight()); cg.setPreferredSize(d); backButton.setX(Display.getInstance().getDisplayWidth() - backButton.getPreferredW()); } }); – Zabihullah Alipour Aug 22 '13 at 15:55
  • when I show a PopUpList the back button dissapears. I tried to set it again with the listDismissed method but, nothing happens. Any idea? – Mun0n Aug 23 '13 at 11:31
  • its working for me!!. can I see your source code? put your source code here(PopUpList, listDismissed method)? – Zabihullah Alipour Aug 23 '13 at 15:40
  • Ok, I will make a new question with the code attached. Thank you very much @AliPour – Mun0n Aug 25 '13 at 19:19
  • I've build a dummy project just to try this issue, but it's working fine. It must be a problem from my other project :-( Thanks – Mun0n Aug 26 '13 at 07:55