如何在通知的观点倒计时计时器?计时器、倒计时、观点、通知

2023-09-07 18:08:27 作者:不闻旧人

我想通了,如何使用,使自定义视图RemoteViews类。我也知道如何使用Chronometer和ProgressBar内部RemoteViews.

I figured out how to make custom views using RemoteViews class. I also know how to use Chronometer and ProgressBar inside of RemoteViews.

但如何做一个倒计时 查看 ,几乎完全一样Chronometer但不同的,这将是代替数数的降低?

But how to make a count down View, almost exactly the same as Chronometer but with the difference that it will be counting down instead of up?

我试图复制源Chronometer类,并修改它,所以它会适合我的需要,但也有像 @ android.view.RemotableViewMethod ,注释,我不能导入到我的项目。不幸的是,没有标注它不工作,因为RemoteViews用它们来传递值。

I tried to copy the source of Chronometer class and modify it so it will fit my needs, but there are annotations like @android.view.RemotableViewMethod, which i can not import to my project. Unfortunately, without annotations it is not working, because RemoteViews is using them to pass values.

我的第二个想法是延长Chronometer类并覆盖适当的方法,但它们是私人

My second idea was to extend the Chronometer class and override proper methods, but they are private.

任何想法,这可能吗? (和额外的问题,因为我不知道:如果该方法被注解,我重写此方法,是继承了注释)

Any ideas, is it possible? (And extra question, because I'm not sure: If the method is annotated and I override this method, is the annotation inherited?)

推荐答案

我不相信你将能够直接与 RemoteViews 使用自定义类即使它从支持类之一派生(注解是的不的继承)。你可以尝试使用的TextView ,使用对 RemoteViews参考倒计时在服务 对象和更新来自那里。

I don't believe you're going to be able to use a custom class directly with RemoteViews even if it's derived from one of the supported classes (annotations are not inherited). You could try using a TextView, counting down in a Service with a reference to the RemoteViews object and updating from there.