这是我的日期选择器对话框代码。我想在我的日期选择器对话框中禁用未来日期选择。
任何人都可以建议如何?
@Override
protected Dialog onCreateDialog(int id)
{
// TODO Auto-generated method stub
switch(id)
{
case 1:
Calendar cal=Calendar.getInstance();
Toast.makeText(DateActivity.this, "- onCreateDialog -", Toast.LENGTH_LONG).show();
return new DatePickerDialog(this,myDateSetListener,cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_YEAR));
default:
return null;
}
}
private DatePickerDialog.OnDateSetListener myDateSetListener = new DatePickerDialog.OnDateSetListener()
{
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
{
// TODO Auto-generated method stub
String date = "Year: " + String.valueOf(year) + "\n"
+ "Month: " + String.valueOf(monthOfYear+1) + "\n"
+ "Day: " + String.valueOf(dayOfMonth);
Toast.makeText(DateActivity.this, date,Toast.LENGTH_LONG).show();
}
};