Skip to content

Instantly share code, notes, and snippets.

@clathrop
Created July 17, 2012 20:49
Show Gist options
  • Save clathrop/3131982 to your computer and use it in GitHub Desktop.
Save clathrop/3131982 to your computer and use it in GitHub Desktop.
Titanium: Date Picker for Android
// This is an example in having a date picker popup and when set, it saves the value to a textfield
var win = Ti.UI.createWindow({
backgroundColor : 'blue',
});
var picker = Ti.UI.createPicker({
});
var txt = Ti.UI.createTextField({
value : '',
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
editable : false,
width: 300
});
txt.addEventListener('click', function(e) {
picker.showDatePickerDialog({
value : new Date(), // some date
callback : function(e) {
if (e.cancel) {
Ti.API.info('user canceled dialog');
} else {
Ti.API.info('value is: ' + e.value);
Ti.API.info('lets see what this object is' + JSON.stringify(e));
selectedDate = e.value;
txt.value = String.formatDate(selectedDate, 'medium');
}
}
});
});
win.add(txt);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment