Android DatePickerDialog的默认日期为1900年1月1日 [英] Android DatePickerDialog default date is Jan/1/1900

查看:568
本文介绍了Android DatePickerDialog的默认日期为1900年1月1日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道这个愚蠢的小虫子。每当我启动DatePickerDialog时,默认的设置日期为Jan / 01/1900。

I can't figure out this stupid little bug. Whenever I initiate the DatePickerDialog, the default set date date is Jan/01/1900.

这很奇怪,因为在平板电脑上,滑块旁边还有一个日历视图,您还可以从中选择日历视图,并在当前日期设置THATS,但是滑块不是t。

It's weird though because on the tablet there's a calendar view next to the slider which you can pick from as well and THATS set on the current date, but the slider isn't.

public static class DatePickerFragment extends DialogFragment implements
        DatePickerDialog.OnDateSetListener {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Log.d("month",Integer.toString(mMonth)); //Is returning current month, like it should

        return new DatePickerDialog(getActivity(), this, mDay, mMonth, mYear); //all set to current date
    }

    public void onDateSet(DatePicker view, int year, int month, int day) {
        dateDue.setText(month + 1 + "/" + day + "/" + year);
    }
}


推荐答案

I是个白痴。构造函数中参数的顺序是年,月然后是日期。

I'm an idiot. Order of parameters in constructor is year, month then date.

这篇关于Android DatePickerDialog的默认日期为1900年1月1日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆