【发布时间】:2016-08-08 14:15:06
【问题描述】:
大家好,我是 android 新手,遇到问题我已经搜索了很多,但没有使用 DatePickerDialog 框获得解决方案,当我运行应用程序时,虽然我设置了最小日期,但它也在选择以前的日期。我也尝试从当前时间中减去 1 秒。 DatePicker 从 1990 年 1 月开始。我希望它从今天开始并阻止以前的日期。谢谢...
public void OnButtonClickDate()
{
btn_date = (Button)findViewById(R.id.button);
edit_date = (EditText)findViewById(R.id.editText);
btn_date.setOnClickListener
(
new View.OnClickListener()
{
@Override
public void onClick(View view)
{
DatePickerDialog datePickerDialog = new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener()
{
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
view.setMinDate(System.currentTimeMillis());
edit_date.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year);
}
}, mYear, mMonth, mDay);
datePickerDialog.show();
}
}
);
}
【问题讨论】:
-
你的格式是怎么回事?这很难阅读:(
-
我很抱歉弄得一团糟......你想让我通过格式化将它发送到 cmets 中吗?
-
您应该使用格式化的代码编辑您以前的帖子 - 这将增加您获得支持的里程。眨眼间,一个人可能会离开可能知道您答案的页面。
标签: android