Form navigation question
I am a new LWUIT user, so to start with, I would like to say a Big Thanks to the team that created it and the community. I don't have much experience with mobile development, and started only recently, with a n application for my own uses. The first approach was with pure MIDP UI classes, and sometimes the screen changing logic got really twisted. Now, with LWUIT, the code is much cleaner, and as I have some experience with Swing, my life is easier.
Suppose I have two forms: FormOne and FormTwo. FormOne has a button whose listener looks like this:
<br /> new SecondForm(FirstForm.this).show();<br />
so it creates a new instance of SecondForm, passes itself as the "previous form", and shows it.
No, second form has a back button, whose action is the following:
<br /> previousForm.show();<br />
The question is, whether this is the correct way to do form navigation? I have serious doubts about this. The first form shows the second, and the second form may show the first one as it has the reference to it, and then the first can create the new second form and show it, I can go back, and so on. The second form seems not to be ever disposed (I don't know what the Form.show() method does), so if I do the switching between forms long enough, I might get an OutOfMemoryError, right?
I can create a single instance of the second form, and reuse it in the first one, but I think that if I switch the forms long enough (probably much much longer), I could get a StackOverflowError (if it exists in JME), as the forms would be showing themselves and the calls to show() would be put on the stack.
For dialogs, I can call dispose() and it just disappears, how do you do this correctly for forms?
Please explain to me the flow of the navigation.
Second question is: what does the showBack() method do? How is it different? I don't fully understand what the docs say, and when I use it it seems not to be any different from show().
Thanks and regards,