It is not possible to add one ui field or manager to two manager or screen s .. each ui field or manager must have at most one parent ( screen or manager ).
So, if you need a LabelField that will hold and show time on different screen s, then you only need to implement some kind of listener that will listen to time changes .. and for each change you have to update screen and LabelField new value. You have already implemented TimerTask , which will provide you with updated data.
[Edited - added later]
you can check the following codes, not verified, but something like this will solve your problem ...
class MyTimerUtil { TimerListener listener = null; public MyTimerUtil() { } public void setTimerListener(TimerListener listener) { this.listener = listener; } public void startTimer() { final int interval = 1000; Timer timer = new Timer(); TimerTask task = new TimerTask() { public void run() {
in the above snippet, you can implement the TimerListener interface in any screen instance and can receive an update every time the event is changed by the MyTimerUtil class. To do this, you need to install an instance of ScreeA (which implements TimerListener ) through setTimerListener() of the MyTimerUtil class.
You must also start the timer by calling startTimer() .
source share