How to make a count down timer in Notification's view?

对着背影说爱祢 提交于 2020-01-02 01:45:38

问题


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

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?

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.

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?)


回答1:


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.



来源:https://stackoverflow.com/questions/8403662/how-to-make-a-count-down-timer-in-notifications-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!