Android 将事件添加到 CalendarView
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22000585/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add event to CalendarView
提问by Cilenco
I think the question says it all: is it possible to display events in the Android default CalendarView
?
我认为这个问题说明了一切:是否可以在 Android 默认中显示事件CalendarView
?
I know that it is made for widgets and not for a real Calendar application but my app should not be a Calendar application. It is only a little feature in my app so I think the View is perfect for my claims. I only can't view events in it, otherwise it is perfect for me.
我知道它是为小部件而不是真正的日历应用程序制作的,但我的应用程序不应该是日历应用程序。它只是我应用程序中的一个小功能,所以我认为 View 非常适合我的主张。我只是无法查看其中的事件,否则它对我来说是完美的。
I read this answerand tried to overwrite the onDraw method from CalenderView
:
我阅读了这个答案,并试图从CalenderView
以下位置覆盖 onDraw 方法:
@Override
protected void onDraw(Canvas canvas)
{
p = new Paint();
p.setColor(Color.RED);
p.setStrokeWidth(10);
super.onDraw(canvas);
canvas.drawRect(0, 0, 100, 100, p);
}
But even this code does not work and no rectangle is displayed. The other 4 methods are private
so I can't overwrite them. Any other ideas how I can solve this problem? I do not want to use a library, but if there is no other way I'm looking for something what is really near to the stock CalendarView
. Or maybe I can create a calendar file which is only visible in my app and not in other calendar apps?
但即使这段代码也不起作用,也没有显示矩形。其他 4 种方法是private
这样我不能覆盖它们。我还有其他想法可以解决这个问题吗?我不想使用图书馆,但如果没有其他方法,我正在寻找真正接近库存的东西CalendarView
。或者我可以创建一个仅在我的应用程序中可见而在其他日历应用程序中不可见的日历文件?
回答by Mehul Joisar
回答by Sun
Shameless plug. I've also written my own android CalendarView which allows you to add events, listeners, provides infinite scrolling and is a gradle project: https://github.com/SundeepK/CompactCalendarView.
无耻的插头。我还编写了自己的 android CalendarView,它允许您添加事件、侦听器、提供无限滚动,并且是一个 gradle 项目:https: //github.com/SundeepK/CompactCalendarView。