I am working on an application in which the user can set the date and time. I want to set the date and time in a single dialog fragment and set it to edit text. Is it possible to use a date and time picker in 1 dialog fragment? If it is, how do you do it? Currently I am getting the time from the dialog fragment and then setting it to the EditText.

My code is

LaterTextView=(TextView)findViewById(R.id.PickUp_later_TextView);



       LaterTextView.setOnClickListener(new View.OnClickListener() {

            @SuppressWarnings("deprecation")
            public void onClick(View v) {
                showDialog(TIME_DIALOG_ID);

                }
        });




}


protected Dialog onCreateDialog(int id) {
    switch (id) {
    case TIME_DIALOG_ID:

        // set time picker as current time
        return new TimePickerDialog(this, timePickerListener, hour, minute,
                false);

    }
    return null;
}

private TimePickerDialog.OnTimeSetListener timePickerListener = new TimePickerDialog.OnTimeSetListener() {
    public void onTimeSet(TimePicker view, int selectedHour,
            int selectedMinute) {
        hour = selectedHour;
        minute = selectedMinute;

        // set current time into TextView
        setDate_time_EditTExt.setText(new StringBuilder().append(pad(hour))
                .append(":").append(pad(minute)));



    }
};
private static String pad(int c) {
    if (c >= 10)
        return String.valueOf(c);
    else
        return "0" + String.valueOf(c);
}

I want to set the date and time from the same dialog fragment.

Edit
Report