When user clicks the edtText the first time the keypad appears, the user needs to click another time so the dialog appears. Even while debugging it reaches the show method of the timePickerDialog, but still on the first time the keypad appears, on the second click the dialog appears
public class NewAssignment extends FragmentActivity implements DatePickerDialog.OnDateSetListener,
TimePickerDialog.OnTimeSetListener
{
EditText timePicker;
timePicker = (EditText) findViewById(R.id.timePicker);
timePicker.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
showTimePickerDialog();
}
});
public void showTimePickerDialog()
{
final Calendar c = Calendar.getInstance();
int hourOfDay = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
TimePickerDialog td = new TimePickerDialog(this, this, hourOfDay, minute, DateFormat.is24HourFormat(this));
td.show();
}
}
i encountered the same problem, while implementing time and date pickers. following code did it for me
timePicker.setInputType(InputType.TYPE_NULL);
but then you would have to click twice to make the time picker dialog appear. so add
timePicker.setFocusable(false);
and everything should work as expected.