开发者

Android: timepicker and datepicker in the same dialog box

I am developing an 开发者_如何学Goapp for android. I have created a timepickerdialog and a datepickerdialog, but the problem is, both of them run in different dialog boxes, which is not what the way I want my app to work :-S Is there any way to create a single dialogbox with both time and date picker dialog boxes in it together?

Thx


You can find a DateTimePicker implementation here:

http://code.google.com/p/datetimepicker/


I have created a custom Alert Dialog as in the Google tutorial. I replaced the ImageView and the TextView with a DatePicker and a TimePicker. I changed the following line:

View layout = inflater.inflate(R.layout.custom_dialog,
                           (ViewGroup) findViewById(R.id.layout_root));

with this:

View layout = inflater.inflate(R.layout.dialog_date_time, 
                           (ViewGroup) findViewById(R.id.datePicker));

For whatever reason the first gave an error, but the second worked. Anyway, I can use the two views in the same dialog window now.


call time picker dialog in datepicker's update time method,It'll not be called at the same time but when you press datepicker's set button,Time picker dialog will open . The method is given in the answer of this link: DateTime picker in android application

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜