钛创建日历事件
我正在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下链接可能对您有帮助。
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.