datepicker show up from text field

You must Login before you can answer or comment on any questions.

I want to do the following:

when people click on a text field they see a date picker.

they click "done" button at the top and the date picker disappears

and they are back on the form.

How can I accomplish this using titanium mobile for iphone ios?

1 Answer

Accepted Answer

hi weina, you can do this in following way

var view1 = Ti.UI.createView({
    width:200,
    height:200
    });
 
    var picker = Ti.UI.createPicker({
        type:Ti.UI.PICKER_TYPE_DATE,
        bottom:0,
        value: new Date()
    });
    var button = Ti.UI.createButton({
        title: "done",
        top:0
    })
    view1.add(picker);
    view1.add(button)
    button.addEventListener("click",function () {
        view1.hide();
    });
    view1.hide();
show this view on click of your textfield in this way
txt.addEventListener('click',function(){
view1.show();
});
i hope this will help you.

Your Answer

Think you can help? Login to answer this question!