×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Feb 2013
    Location
    Madrid
    Posts
    84

    Back Button LWUIT App

    I'm building an app in LWUIT and using full screen with a custom header bar.

    When I set the full screen propiertie, I lose all the native back buttons, so know I will have to build them.

    My issue is, how to build a back button which can look like the native back button?

    It must be located in the bottom right part of the screen and his background must be transparent too. I need it to looks like the native back button.

    Anyone has build this before?

    Some code will be appreciated.

  2. #2
    Registered User
    Join Date
    Feb 2013
    Location
    Madrid
    Posts
    84

    Re: Back Button LWUIT App

    I get this answer from stackoverflow. It's working fine for me, only needs some fixes with orientation changes

    public void startApp() {
    Display.init(this);
    Form f = new Form();

    //set CoordinateLayout to f
    f.setLayout(new CoordinateLayout(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight()));

    //Create a ComponentGroup for keep all components except backbutton
    ComponentGroup cg = new ComponentGroup();

    //set BorderLayout(or BoxLayout,...) to cg
    cg.setLayout(new BorderLayout());
    Dimension d = new Dimension(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight());
    cg.setPreferredSize(d);

    //Add any component to cg
    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("Enter Some Text"));
    cg.setX(0);
    cg.setY(0);

    //Create native back button, don't add this to cg
    Button backButton = new Button("BackButton");
    backButton.getStyle().setBgColor(0x2233ff);

    //backButton always show in the bottom right side of the screen
    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();

    }

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Back Button LWUIT App

    You can capture the Canvas/Screen sizeChangedEvent() - recreate a new object of this form (with new height & width) and call its show - so that the new form is repainted in the new orientation.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

Similar Threads

  1. How to catch Asha 501 Back button in LWUIT?
    By mikkori in forum Mobile Java UI and User Experience
    Replies: 3
    Last Post: 2013-12-17, 10:31
  2. LWUIT- adding back command to button
    By herahadi in forum Mobile Java General
    Replies: 0
    Last Post: 2013-03-07, 08:53
  3. Replies: 2
    Last Post: 2012-11-23, 07:39
  4. Replies: 3
    Last Post: 2011-10-31, 13:37
  5. Replies: 1
    Last Post: 2010-04-25, 23:03

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×