钛创建日历事件

发布于 2024-12-20 09:12:23 字数 1506 浏览 3 评论 0原文

我正在尝试在 Android 平台的 Titanium 应用程序中创建日历事件。为此,我使用下面的代码,它没有给出任何错误,也没有创建任何日历事件

var calendars = Ti.Android.Calendar.selectableCalendars;
        var names =[];
        for (var i = 0; i<calendars.length; i++) {
            names.push(calendars[i].name);
        }

        var calendarDialog = Titanium.UI.createOptionDialog({
            title: 'Select a Calendar',
            options: names,
            cancel:1
        });
        calendarDialog.addEventListener('click', function(e){
            var ci = e.index+1;
            var calendar = Ti.Android.Calendar.getCalendarById(ci);

            var eventBegins = new Date(2011, 12, 26, 12, 0, 0);
            var eventEnds = new Date(2011, 12, 26, 14, 0, 0);
            var hasReminder = true;
            var details = {
                title: 'i m testing',
                description: 'message',
                begin: eventBegins,
                end: eventEnds,
                hasAlarm:true,
                allDay:true
            };

            var event = calendar.createEvent(details);

            if (hasReminder)
            {
                var reminderDetails = {
                    minutes: 10,
                    method: Ti.Android.Calendar.METHOD_ALERT
                };

                event.createReminder(reminderDetails);
            }

            alert('Event was created!');
        });
        calendarDialog.show();

有人帮助我解决这个问题..我的Titanium SDK版本是1.7.5,我已经在Android 2.3手机中尝试过这个

I am trying to create calendar event in my Titanium App for Android Platform. For that I am using below code, It does't give any error also didn't to create any calendar events

var calendars = Ti.Android.Calendar.selectableCalendars;
        var names =[];
        for (var i = 0; i<calendars.length; i++) {
            names.push(calendars[i].name);
        }

        var calendarDialog = Titanium.UI.createOptionDialog({
            title: 'Select a Calendar',
            options: names,
            cancel:1
        });
        calendarDialog.addEventListener('click', function(e){
            var ci = e.index+1;
            var calendar = Ti.Android.Calendar.getCalendarById(ci);

            var eventBegins = new Date(2011, 12, 26, 12, 0, 0);
            var eventEnds = new Date(2011, 12, 26, 14, 0, 0);
            var hasReminder = true;
            var details = {
                title: 'i m testing',
                description: 'message',
                begin: eventBegins,
                end: eventEnds,
                hasAlarm:true,
                allDay:true
            };

            var event = calendar.createEvent(details);

            if (hasReminder)
            {
                var reminderDetails = {
                    minutes: 10,
                    method: Ti.Android.Calendar.METHOD_ALERT
                };

                event.createReminder(reminderDetails);
            }

            alert('Event was created!');
        });
        calendarDialog.show();

Anyone help me to solve this issue.. My Titanium SDK version is 1.7.5, I have tried this in Android 2.3 Phone

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

预谋 2024-12-27 09:12:23

以下链接可能对您有帮助。

https://github.com/codememan/Titanium-Calendar

您需要在中添加必要的文件然后您可以从 .js 文件导入并运行代码。

The following link might help you.

https://github.com/codememan/Titanium-Calendar

you need to add the necessary file in your project then you can import and run the Code from the .js file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文