hi..
how to display d previous screen in d midlet?just previous screen ?with out using d this command like
display.setCurrent(name of last screen());
hi..
how to display d previous screen in d midlet?just previous screen ?with out using d this command like
display.setCurrent(name of last screen());
There's not a standard way to do this. You could try mantaining an history of visited screen within a Vector, and when goind back you'll take the last inserted element (removing it from the Vector) and display as current screen.
Pit
hi...
how to create such a vector of history of visited screen?
Here's a simple class that can manage next/previous screens. You should use it to change screens within your j2me app.
Pitimport java.util.Vector;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
public class ScreenManager
{
MIDlet midlet = null;
Vector history = null;
Displayable currentScreen = null;
public ScreenManager(MIDlet midlet)
{
this.history = new Vector();
this.midlet = midlet;
}
public void gotoScreen(Displayable nextScreen)
{
if(currentScreen != null)
{
history.addElement(currentScreen);
}
currentScreen = nextScreen;
Display.getDisplay(midlet).setCurrent(nextScreen);
}
public void gotoPreviousScreen()
{
if(history.size() > 0)
{
currentScreen = (Displayable)history.lastElement();
history.removeElement(currentScreen);
Display.getDisplay(midlet).setCurrent(currentScreen);
}
}
}
You should instantiate an object of this class, and then use it everytime you need to go to another screen (so, you should not call directly Display.getDisplay(midlet).setCurrent() method).
So, let's say u'r on screen A and want to go to screen B, you'll call:
managerInstance.gotoScreen(bScreenInstance);
Then, if you want to go back to previous screen, you'll call:
managerInstance.gotoPreviousScreen();
Anyway, this is only a basic example of how screen management can be implemented. You can freely implement yours once you've understood the base concept.
Pit