×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    27

    Keep the event listener while change displayable in form

    Hi.

    I'm creating a form-based app where the user can navigate to next form with "Next" button and to previous form with "Back" button.

    Each form basically has a few items which are clickable and have listener attached to them.

    While clicking "Back" goes to displaying previous form but those events attached to those items are gone.
    How can i keep those events intact?

    What i do is define a Displayable object to point to that previous form
    Code:
     
    private Display display;
    private Displayable form;
    .
    .
    .
    
    display = Display.getDisplay(this);
    form = display.getCurrent();
    .
    .
    .
    and then, set the displayable to that previous form once "back" is clicked.
    Code:
     display.setCurrent(form);
    I just listed out the code snippets where it's relevant.

    Please help on how to maintain the listeners for the items i mentioned above.

    Thanks.

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Keep the event listener while change displayable in form

    Simply attach the same listener to both Displayables. Both Forms can use the same CommandListener.

    Code:
    public class MyApplication extends MIDlet implements CommandListener {
        private Form form1;
        private Form form2;
        public void startApp() {
            form1 = new Form("1");
            form1.setCommandListener(this);
            form2 = new Form("2");
            form2.setCommandListener(this);
        }
        //  ... more code...
    }
    Graham.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    27

    Re: Keep the event listener while change displayable in form

    Thanks, Graham. It's working now!

    Quote Originally Posted by grahamhughes View Post
    Simply attach the same listener to both Displayables. Both Forms can use the same CommandListener.

    Code:
    public class MyApplication extends MIDlet implements CommandListener {
        private Form form1;
        private Form form2;
        public void startApp() {
            form1 = new Form("1");
            form1.setCommandListener(this);
            form2 = new Form("2");
            form2.setCommandListener(this);
        }
        //  ... more code...
    }
    Graham.

Similar Threads

  1. Choicegroup + event listener
    By shirodas in forum Mobile Java General
    Replies: 3
    Last Post: 2008-12-01, 15:19
  2. Displayable change (again)
    By Wontar in forum Mobile Java General
    Replies: 0
    Last Post: 2007-01-13, 16:14
  3. Install a system event listener?
    By profoundwhispers in forum Symbian
    Replies: 2
    Last Post: 2005-03-13, 13:24
  4. how to write alert with event listener
    By eng00787 in forum Mobile Java General
    Replies: 1
    Last Post: 2004-02-14, 00:17
  5. Event Listener Application
    By vincent32 in forum Symbian
    Replies: 0
    Last Post: 2002-11-12, 12:32

Posting Permissions

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