In previous post am talking about how create TimePickerDialog with 15 minute interval
but when user click on Editbox of numberpicker, android soft keyboard lunch,
is there any way to disable writing inside a timepicker using keyboard? yes used this line
myDatePicker.setDescendantFocusability(DatePicker.FOCUS_BLOCK_DESCENDANTS);
how and where in dialog
just create a customize TimePickerDialog class as previous post mentions
see below sample code
public class TimePickerDialogs extends TimePickerDialog{ private TimePicker mTimePicker; private OnTimeSetListener mCallback; public TimePickerDialogs(Context arg0, OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView) { super(arg0, callBack, hourOfDay, minute, is24HourView); // TODO Auto-generated constructor stub this.mCallback = callBack; mTimePicker = new TimePicker(arg0); mTimePicker.setDescendantFocusability(TimePicker.FOCUS_BLOCK_DESCENDANTS); mTimePicker.setIs24HourView(is24HourView); mTimePicker.setCurrentHour(hourOfDay); mTimePicker.setCurrentMinute(minute); mTimePicker.setOnTimeChangedListener(this); setView(mTimePicker); } @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub tryNotifyTimeSet(); } private void tryNotifyTimeSet() { if (mCallback != null) { mTimePicker.clearFocus(); mCallback.onTimeSet(mTimePicker, mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute()); } } @Override public void onTimeChanged(TimePicker view, int hourOfDay, int minute) { // TODO Auto-generated method stub //super.onTimeChanged(arg0, arg1, arg2); if (mIgnoreEvent) return; if (minute%TIME_PICKER_INTERVAL!=0){ int minuteFloor=minute-(minute%TIME_PICKER_INTERVAL); minute=minuteFloor + (minute==minuteFloor+1 ? TIME_PICKER_INTERVAL : 0); if (minute==60) minute=0; mIgnoreEvent=true; view.setCurrentMinute(minute); mIgnoreEvent=false; } } private final int TIME_PICKER_INTERVAL=15; private boolean mIgnoreEvent=false; }
Thanks for the post. However, I can still able to open edit text.
ReplyDelete