Created
July 17, 2012 20:49
-
-
Save clathrop/3131982 to your computer and use it in GitHub Desktop.
Titanium: Date Picker for Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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