学习TI 记录一下
1.确认对话框
Js代码
var a = Titanium.UI.createAlertDialog({
title:'添加人员信息',
message:"人员添加成功",
buttonNames: ['确定']
});
//a.addEventListener('click', function(e) {
// alert("Now you should see this one, assuming you dismissed the first alert");
//});
a.show();
2.可选对话框
Js代码
var dialog = Titanium.UI.createOptionDialog({
title: '添加人员信息',
options: ['成功','失败'],
cancel:1
});
dialog.show();
3.自定义对话框
Js代码
var minDate = new Date();
minDate.setFullYear(2009);
minDate.setMonth(0);
minDate.setDate(1);
var maxDate = new Date();
maxDate.setFullYear(2009);
maxDate.setMonth(11);
maxDate.setDate(31);
var value = new Date();
value.setFullYear(2009);
value.setMonth(0);
value.setDate(1);
var view=Ti.UI.createView({
height:100,
width:100
});
var picker = Ti.UI.createPicker({
type:Ti.UI.PICKER_TYPE_DATE_AND_TIME,
minDate:minDate,
maxDate:maxDate,
value:value
});
// turn on the selection indicator (off by default)
picker.selectionIndicator = true;
view.add(picker);
var dialog = Titanium.UI.createAlertDialog({
title:'添加人员信息',
message:"人员添加成功",
androidView:view
});
dialog.show();
4.发送邮件对话框
Js代码
var emailDialog = Titanium.UI.createEmailDialog();
if (!emailDialog.isSupported()) {
Ti.UI.createAlertDialog({
title:'Error',
message:'Email not available'
}).show();
return;
}
emailDialog.setSubject('Hello from Titanium!');
emailDialog.setToRecipients(['foo@yahoo.com']);
emailDialog.setCcRecipients(['bar@yahoo.com']);
emailDialog.setBccRecipients(['blah@yahoo.com']);
if (Ti.Platform.name == 'iPhone OS') {
emailDialog.setMessageBody('Appcelerator Titanium Rocks!å');
emailDialog.setHtml(true);
emailDialog.setBarColor('#336699');
} else {
emailDialog.setMessageBody('Appcelerator Titanium Rocks!');
}
// attach a blob
emailDialog.addAttachment(event.media);
// attach a file
var f = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'cricket.wav');
emailDialog.addAttachment(f);
emailDialog.addEventListener('complete',function(e)
{
if (e.result == emailDialog.SENT)
{
if (Ti.Platform.osname != 'android') {
// android doesn't give us useful result codes.
// it anyway shows a toast.
alert("message was sent");
}
}
else
{
alert("message was not sent. result = " + e.result);
}
});
emailDialog.open();