1

I am currently trying to make a dial style alert dialog to pick numbers within a certain range.

I have come across using the time picker dialog to create the dial effect, but I noticed the dialog would need has to pass the HourOfDay and minutes.

TimePickerDialog(Context context, TimePickerDialog.OnTimeSetListener listener, int hourOfDay, int minute, boolean is24HourView)

How do I augment this to have it take 1 int? And is the use of TimePicker to try and display the values in dial form valid?

Thanks

2 Answers2

1

Hi

No it is not valid to show time picker for get input int from user. Time picker android system control and it will give you hh:mm:ss format input as pet user selection so it is not valid.

If you want to do something like this then you can show one alert dialog and embed one view with buttons and set int values on that button. So user can press button and you can get int from it.

Vickyexpert
  • 3,147
  • 5
  • 21
  • 34
0
  • for time picker within range
  • for minimun of 1 hour from currunt time is refer below line

  • c.get(Calendar.HOUR_OF_DAY)-1,c.get(Calendar.MINUTE),false);

  • maximum of 1 hour from currunt time is refer below

  • c.get(Calendar.HOUR_OF_DAY)-1,c.get(Calendar.MINUTE),false);

    btnTime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {

            TimePickerDialog.OnTimeSetListener timePickerListener = new TimePickerDialog.OnTimeSetListener() {
                @Override
                public void onTimeSet(TimePicker view, int hour, int minute) {
    
                }
            };
            Calendar c = Calendar.getInstance();
    
            final TimePickerDialog timePickerDialog = new TimePickerDialog(Main23Activity.this,timePickerListener,
                    c.get(Calendar.HOUR_OF_DAY),c.get(Calendar.MINUTE)+5,false);
            timePickerDialog.show();
    
        }
    });
    
Yogesh Borhade
  • 694
  • 1
  • 10
  • 24
  • use min date and max date bothe things are available in and DatePicker And Timepicker. by using Min and Max function u can select the range between min and max – Yogesh Borhade May 14 '16 at 04:57