I am using timepicker and datepicker in my app. i want to disable keyboard in both these. i am able to disable keyboard in date picker with below code.
datePickerDialog.getDatePicker().setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
but not getting how to disable keyboard in timepickerdialog.
i tried below popular example but still no use
public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener
{
private TimePickerDialog timePickerDialog;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
//Default 6:00
timePickerDialog = new TimePickerDialog(getActivity(), this, 6, 0, android.text.format.DateFormat.is24HourFormat(getActivity()));
return timePickerDialog;
}
@Override
public void onStart()
{
super.onStart();
final View hourView = timePickerDialog.findViewById(Resources.getSystem().getIdentifier("hour", "id", "android"));
final View minuteView = timePickerDialog.findViewById(Resources.getSystem().getIdentifier("minute", "id", "android"));
if (hourView != null && hourView instanceof NumberPicker)
{
((NumberPicker) hourView).setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS);
}
if (minuteView != null && minuteView instanceof NumberPicker)
{
((NumberPicker) minuteView).setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS);
}
}
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute)
{
((MenuEditActivity) getActivity()).setRecipeTime(hourOfDay, minute);
}
@Override
public void onCancel(DialogInterface dialog)
{
super.onCancel(dialog);
}
}
any help?
use this for time picker
Solved the issue by creating custom Dialog and extending TimePickerDialogClass
}
Added the following code in fixSpinner() function
timePicker.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS)
And use it as
try this