ダイアログを表示するために呼び出すと、アプリでこの問題が発生します。何らかの理由で 2 回呼び出されています。これは、Android 4.1 以降でのみ発生します。下位バージョンは問題なく動作するので、コードの問題ではないと思います。
以前にこの問題に\遭遇したことはありませんか?
ここにコード:
Button edit = (Button) ad.findViewById(R.id.editBtn);
edit.setTypeface(roboto);
edit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setDate();
ad.dismiss();
}
});
ad.show();
ad.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
shiftsActivity.setPressed(true);
}
});
}
public void setDate() {
// Initialize and open the set date dialog
DatePickerDialog setDateDialog = new DatePickerDialog(Shifts.this,
datePickerListener, dateAndTime.get(Calendar.YEAR),
dateAndTime.get(Calendar.MONTH),
dateAndTime.get(Calendar.DAY_OF_MONTH));
setDateDialog.setTitle("Set Date");
setDateDialog.show();
}
public void setStartTime() {
TimePickerDialog setStartTimeDialog = new TimePickerDialog(Shifts.this,
startTimePicker, dateAndTime.get(Calendar.HOUR),
dateAndTime.get(Calendar.MINUTE), true);
setStartTimeDialog.setTitle("Started At:");
setStartTimeDialog.show();
}
public void setEndTime() {
TimePickerDialog setEndTimeDialog = new TimePickerDialog(Shifts.this,
setEndTime, dateAndTime.get(Calendar.HOUR),
dateAndTime.get(Calendar.MINUTE), true);
setEndTimeDialog.setTitle("Ended:");
setEndTimeDialog.show();
}
TimePickerDialog.OnTimeSetListener startTimePicker = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
startIntHours = hourOfDay;
startIntMinutes = minute;
editStartTime = String.format("%02d", hourOfDay) + ":"
+ String.format("%02d", minute);
setEndTime();
}
};
TimePickerDialog.OnTimeSetListener setEndTime = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
finishIntHours = hourOfDay;
finsihIntMinutes = minute;
if (finishIntHours < startIntHours) {
finishIntHours = finishIntHours + Utility.HOURS_TIME_UNIT;
}
if (finsihIntMinutes < startIntMinutes) {
finsihIntMinutes = finsihIntMinutes + Utility.MINUTES_TIME_UNIT;
}
totalHours = finishIntHours - startIntHours;
totalMinutes = finsihIntMinutes - startIntMinutes;
Log.i("TotalHours in time picker", "" + totalHours);
Log.i("Totalminute in time picker", "" + totalMinutes);
editEndTime = String.format("%02d", hourOfDay) + ":"
+ String.format("%02d", minute);
replace(Shifts.view, Shifts.position);
}
};