解决方案没有找到它,我花了几个小时来应对这个挑战。 如何获得日期以查看当您按下“今天”按钮时的情况?如何在android中设置DatePickerDialog中的日期?
想要获得按下“今天”按钮时显示的日期。 而且,我们相信尝试将信息添加到指定日期的屏幕显示的过程。在外部类中定义
DatePickerDialog dpdialog = new DatePickerDialog(me, new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int pickyear, int monthOfYear,
int dayOfMonth) {
}
}, year, month-1, day);
// Dialog(Positive Button)
dpdialog.setButton(
DialogInterface.BUTTON_POSITIVE,
"set",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Positive Button
// How to get the date set
String day = dpdialog.getDayOfMonth();
String month = dpdialog.getMonth() + 1;
String year = dpdialog.getYear();
}
}
);
// Dialog (Negative Button)
dpdialog.setButton(
DialogInterface.BUTTON_NEGATIVE,
"cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Negative Button
}
}
);
// Dialog(Neutral Button)
dpdialog.setButton(
DialogInterface.BUTTON_NEUTRAL,
"today",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Neutral Button
}
}
);
dpdialog.show();
没有人去打扰,如果你回答你的问题不要打扰你的代码格式。 – 2012-03-13 02:47:12
对不起。 我应该有更多的问题和整理。 回来再次写我自己的,我试图提高可读性。 – user1265435 2012-03-13 03:19:13