1

In my project I am going to on one List then clicking on the item of that List going to new Form there is another List on which by clicking going to next Form.

These Forms are not different Forms, they are in a single Form but they are added in a Container and as click on List item it is visualized. The problem is I have a back Button on each Container but I have to code all time when I need to go to back to previous page.

I need a solution such that there will only one back Command on which by clicking it should go to it's current page's previous page. Need only one Command on which by clicking it goes to its previous page.

I know how to code this with COMMAND.BACK in lcdui but need suggestion for LWUIT.

Mun0n
  • 4,438
  • 4
  • 28
  • 46
5extremers
  • 66
  • 2
  • 10

1 Answers1

4

I wouldn't use a Buttonto do this stuff. My suggestion is, use a Command and implement a switch or some if else to set the different back functionality. So:

int pressed = 0;
Command c = new Command("Back"){

        public void actionPerformed(ActionEvent evt) {
            super.actionPerformed(evt);
            switch(pressed){
              case 0:
                //Functionality for first case
              case 1:
                //Functionality for second case
              case 2:
                //Functionality for third case
            }


        }
    };
form.addCommmand(c);

increment the pressed variable every time you press in the Container. and reset it when its necessary.

gnat
  • 6,213
  • 108
  • 53
  • 73
Mun0n
  • 4,438
  • 4
  • 28
  • 46
  • Thank you very much my concept is very much clear by this help but can u suggest me super can not be used for back to my previous page so how can i use it to back to previous page using super??? – 5extremers Jun 21 '12 at 10:52
  • But, You don't have any Forms to go back. All of your events happens in the same Form but the container changes, no? – Mun0n Jun 21 '12 at 11:01
  • 1
    Yes I have only one container whose content is changed at each event and I have done by using functions suppose if I have to change content then the layout is in function which is applied on action.But from all this changes if I need to back to containers previous stage then I have to use multiple back which I don't want to use so can u help me?? – 5extremers Jun 21 '12 at 11:08
  • But with the "Back" example that I've given to you, you can put the different actions with if else and only use one back command...put some code, it's hard to me to see your issue – Mun0n Jun 21 '12 at 11:15
  • Suppose there is project named as add_full_name and i have done it with one container but updating it 3 times .First i am inserting name in first textfield then click on next named Command Button then on clicking it Container is changed by middlename text field at that page two Commands next and back then again clicking on next same container is updated with last name textfield now there is only back.Now this is my project in which i need to use single back Command which can be used for all this container to go to previous container.I need logic that how can i go to previous container. – 5extremers Jun 21 '12 at 12:37
  • Thank you jmunoz very much i am trying it but if it does not help in this it can help me at any time so thank you very much – 5extremers Jun 21 '12 at 15:32