var view = Ti.UI.createView();
// ---------- Switch
var basicSwitch = Ti.UI.createSwitch({
value:true,
top: 30, right: 30
});
view.add(basicSwitch);
// ---------- Picker
var picker = Ti.UI.createPicker({
top:100, right: 30
});
var list = ['Bananas', 'Strawberries','Mangos','Grapes'];
var data = [];
for(var i = 0; i
data[i]=Ti.UI.createPickerRow({title:list[i], rowIndex: i});
}
// ---------- Switch
var basicSwitch = Ti.UI.createSwitch({
value:true,
top: 30, right: 30
});
view.add(basicSwitch);
// ---------- Picker
var picker = Ti.UI.createPicker({
top:100, right: 30
});
var list = ['Bananas', 'Strawberries','Mangos','Grapes'];
var data = [];
for(var i = 0; i
data[i]=Ti.UI.createPickerRow({title:list[i], rowIndex: i});
}
picker.add(data);
picker.selectionIndicator = true;
picker.addEventListener("change", function(e){
Ti.API.info("changed: " + e.rowIndex );
});
view.add(picker);
//-- date picker
var datepicker = Ti.UI.createPicker({
type: Titanium.UI.PICKER_TYPE_DATE,
top:200
});
datepicker.addEventListener("change", function(e){
Ti.API.info("changed: " + e.value );
});
view.add(datepicker);
//-- button
var button = Titanium.UI.createButton({
title: 'Get Result',
top: 420
});
button.addEventListener("click", function(e){
Ti.API.info("switch: " + basicSwitch.value);
Ti.API.info("picker: " + picker.getSelectedRow(0).rowIndex);
Ti.API.info("date picker: " + datepicker.value);
//-- Alert Dialog
var dialog = Ti.UI.createAlertDialog({
message: 'You have selected switch: ' + basicSwitch.value,
cancel: 1,
buttonNames: ["OK",'Try Again', 'Cancel'],
title: 'Button Clicked'
});
dialog.addEventListener('click', function(e){
Ti.API.info("dialog ended with: " + e.index);
});
dialog.show();
});
view.add(button);
No comments:
Post a Comment