How to I change the TimePicker's mode to Spinner dynamically?
I am trying to add a TimePicker view to my LinearLayout inside a Dialog. However, when I instantiate a TimePicker instance, it has no methods such as setTimePickerMode()
. I know I can do this in the XML file by setting the attribute, but I want to do it dynamically.
I use this line of code to add my TimePicker:
myLinearLayout.addView(new TimePicker(myDialog.getContext()));
It shows the default Clock style, but I want it to be in the spinner mode. I didn't use the TimePickerDialog()
because I want it to be inside my LinearLayout, not a independent dialog.
you have to do something like that
myLinearLayout.addView(new TimePicker(new ContextThemeWrapper(myDialog.getContext(), android.R.style.Theme_Holo_Light_Dialog_NoActionBar)));