ARR.s ARR.s - 1 month ago 19
Android Question

How to create TimePickerDialog android

I want to create TimePickerDialog and theme is sample dialog.

but I follow this link


http://www.android-examples.com/create-timepickerdialog-to-select-time-in-12-hours-format-android/


result is not simple dialog

result is

enter image description here

I want

enter image description here

How to set this ?

and sorry My image is so large.

Answer Source

I have made one method for old TimePickerDialog...i have same situation like you..this is working great for me..

Use below method

    public void showHourPicker() {
            final Calendar myCalender = Calendar.getInstance();
            int hour = myCalender.get(Calendar.HOUR_OF_DAY);
            int minute = myCalender.get(Calendar.MINUTE);


            TimePickerDialog.OnTimeSetListener myTimeListener = new TimePickerDialog.OnTimeSetListener() {
                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                    if (view.isShown()) {
                        myCalender.set(Calendar.HOUR_OF_DAY, hourOfDay);
                        myCalender.set(Calendar.MINUTE, minute);

                    }
                }
            };
            TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), android.R.style.Theme_Holo_Light_Dialog_NoActionBar, myTimeListener, hour, minute, true);
            timePickerDialog.setTitle("Choose hour:");
  timePickerDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
            timePickerDialog.show();
        }

Hope this will help you...let me know if you need any help