04-19-2010 01:36 PM
Hello.
I'm trying to create toggeable MenuItem. My code is:
MenuItem trackingMenu = new MenuItem("Stop tracking", 100, 10) {
public void run() {
boolean tracking = device.getTracking();
device.setTracking(!tracking);
if(tracking){
this.setText("Stop tracking");
} else {
this.setText("Start tracking");
}
}
};
Device is indeed changing it's tracking state, but text on the trackingMenu doesn't. Is it possible to change text that way and where is my mistake?
Thanks,
Andrey.
Solved! Go to Solution.
04-19-2010 01:39 PM
This needs to be done in the makeMenu() override, so that the text is changed every time the menu is displayed.
04-19-2010 08:10 PM
I think I have changed text on a menu item in the way described. However you must make sure that the screen, or more accurately, the MenuItem is NOT recreated. If it is recreated, then you need to run code to set the state of the menu correctly.