這是我的代碼。給一些代碼如何禁用此代碼中的過去時間以及如何使用android時間選擇器對話框應用此操作。時間選取器對話框類沒有任何setMinTime方法以及如何獲取它。如何禁用在android中定時器選擇器對話框上的過去時間
time.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Calendar mcurrentTime = Calendar.getInstance();
int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
int minute = mcurrentTime.get(Calendar.MINUTE);
TimePickerDialog mTimePicker;
mTimePicker = new TimePickerDialog(
FillServiceDetailActivity.this,
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker,
int selectedHour, int selectedMinute) {
String AM_PM;
int hour;
String[] sp=currentTime.split(":");
int hour1=Integer.parseInt(sp[0]);
int min1=Integer.parseInt(sp[1]);
//Toast.makeText(FillServiceDetailActivity.this,"selected hour:\t"+String.valueOf(selectedHour),Toast.LENGTH_LONG).show();
String timeSet = "";
if (selectedHour > 12 && hour1>12) {
selectedHour -= 12;
hour1-=12;
timeSet = "PM";
} else if (selectedHour == 0) {
selectedHour += 12;
timeSet = "AM";
} else if (selectedHour == 12)
timeSet = "PM";
else
timeSet = "AM";
String minutes = "";
if (selectedMinute < 10)
minutes = "0" + selectedMinute;
else
minutes = String.valueOf(selectedMinute);
/*if(selectedHour>12) {
hour = selectedHour - 12;
AM_PM = "PM";
} else if(selectedHour==12)
{
hour=selectedHour;
AM_PM="PM";
}
else {
hour=selectedHour;
AM_PM="AM";
}*/
//Toast.makeText(FillServiceDetailActivity.this,String.valueOf(hour1),Toast.LENGTH_LONG).show();
//Toast.makeText(FillServiceDetailActivity.this,String.valueOf(selectedHour),Toast.LENGTH_LONG).show();
time.setText(selectedHour + ":" + minutes + "\t" + timeSet);
}
}, hour, minute, false);// Yes 24 hour time
mTimePicker.setTitle("Select Time");
mTimePicker.show();
}
});
的可能的複製[安卓TimePickerDialog設置最大時間(http://stackoverflow.com/questions/13516389/android-timepickerdialog-set-max-time) –