当用户第一次出现键盘时单击edtText时,用户需要再次单击以显示对话框。即使在调试时它到达timePickerDialog的show方法,但仍然在键盘第一次出现时,在第二次单击时出现对话框
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();
}
}
答案 0 :(得分:1)
我遇到同样的问题,同时实施时间和日期选择器。以下代码为我做了
timePicker.setInputType(InputType.TYPE_NULL);
但是您必须单击两次才能显示时间选择器对话框。所以添加
timePicker.setFocusable(false);
并且一切都应该按预期工作。