0
我有通知面板天文台表,我用实例如何暂停和恢复通知面板中的天文台?
remoteView.setChronometer(R.id.notification_timer, SystemClock.elapsedRealtime(),
null, true);
我应该如何暂停计时器,并恢复它,当我呼吁通知面板暂停/播放按钮?
在此先感谢!
我有通知面板天文台表,我用实例如何暂停和恢复通知面板中的天文台?
remoteView.setChronometer(R.id.notification_timer, SystemClock.elapsedRealtime(),
null, true);
我应该如何暂停计时器,并恢复它,当我呼吁通知面板暂停/播放按钮?
在此先感谢!
试试这个代码时暂停:
long timeDifference = 0;
Chronometer chronometer = (Chronometer) findViewById(R.id.notification_timer);
timeDifference = chronometer.getBase() - SystemClock.elapsedRealtime();
remoteView.setChronometer(R.id.notification_timer, SystemClock.elapsedRealtime(),
null, false);
当您恢复您的计时器,
remoteView.setChronometer(R.id.notification_timer,
timeDifference + SystemClock.elapsedRealtime(), null, true);
希望这有助于。
我得到“方法findViewById(int)未定义”的类..我可以解决这个问题? –
@JaswanthKumar很好,它在View类中定义。你需要找到一种方法来访问你的代码:http://developer.android.com/reference/android/app/Activity.html#findViewById(int) – SLee
无论如何,我可以做到这一点没有chronome.getbase( )? –