[英]How would i pass a timer from one fragment to another?
Suppose i have a timer which uses a TextView
in Fragment A. And i want to use this timer in Fragment B. How would i do it? 假设我有一个在片段A中使用TextView
的计时器。我想在片段B中使用此计时器。我该怎么做? This is the code which is being used in Fragment A to set the timer... 这是片段A中用于设置计时器的代码...
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
long totalDuration = mp.getDuration();
long currentDuration = mp.getCurrentPosition();
// Displaying total duration time
songTotalDurationLabel.setText(""+utils.milliSecondsToTimer(totalDuration));
// Displaying current time
songCurrentDurationLabel.setText(""+utils.milliSecondsToTimer(currentDuration));
// Running this thread after 100 milliseconds
mHandler.postDelayed(this, 100);
}
};
Now i want to use the timer that's associated with the songCurrentDurationLabel
TextView, in Fragment B as well. 现在,我也想使用与片段B中与songCurrentDurationLabel
TextView关联的计时器。
How would i go about solving this? 我将如何解决这个问题?
Thanks! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.