Reputation: 1326
I use this code:
public class CustomTimePickerDialog extends TimePickerDialog {
private static final String TAG = CustomTimePickerDialog.class.getSimpleName();
public CustomTimePickerDialog(Context context, OnTimeSetListener listener, int hourOfDay, int minute, boolean is24HourView, String databaseTimeById) {
super(context, listener, hourOfDay, minute, is24HourView);
}
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
Log.d(TAG, "onTimeChanged");
}
but onTimeChanged
is not called only in API 21. What could be the problem? Or at least how to do it differently?
I tried extends MyTimePickerDialog
from AlertDialog
and setting custom view with TimePicker like this setView(viewWithTimePicker)
, and then use the method timePicker.setOnTimeChanged(this)
. It working in API: 23, 22, 16 (!) but not in 21 (Android 5.0). Need help.
Upvotes: 2
Views: 1534
Reputation: 1388
I had same issue with Lolipop so I added
android:timePickerMode="spinner" as timePickerMode and It worked.
<TimePicker
android:id="@+id/timepick_start"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:timePickerMode="spinner"/>
Try this.
Upvotes: 3
Reputation: 8149
I think you forget to implements TimePickerDialog.OnTimeSetListener
public class CustomTimePickerDialog extends TimePickerDialog implements TimePickerDialog.OnTimeSetListener{
Upvotes: 1