重启活动时的奇怪之处

时间:2014-01-12 14:34:58

标签: android datepicker

我的活动有问题。 我认为问题几乎和中国一样 this post.

问题是。我还没有listView。我有一个datePicker

protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DATE_DIALOG_ID:
       // set date picker as current date
        Calendar cal = Calendar.getInstance();

        SimpleDateFormat year_sdf = new SimpleDateFormat("yyyy");
        SimpleDateFormat month_sdf = new SimpleDateFormat("M");
        SimpleDateFormat day_sdf = new SimpleDateFormat("d");

        year = Integer.parseInt(year_sdf.format(cal.getTime()));
        month = Integer.parseInt(month_sdf.format(cal.getTime()))-1;
        day = Integer.parseInt(day_sdf.format(cal.getTime()));
       return new DatePickerDialog(this, datePickerListener, 
                     year, month,day);}

这里我有一个在datePicker上按下完成按钮时调用的函数:

private DatePickerDialog.OnDateSetListener datePickerListener 
            = new DatePickerDialog.OnDateSetListener() {

    // when dialog box is closed, below method will be called.
    public void onDateSet(DatePicker view, int selectedYear,
            int selectedMonth, int selectedDay) {
        Log.e("TCPClient","datePicker is there");
        year = selectedYear;
        month = selectedMonth+1;
        day = selectedDay;

        StringBuilder dateOfDelivery = new StringBuilder().append(day).append(".").append(month).append(".").append(year);}

我想在其他帖子中,datePicker想要指向一个不存在的对象。

非常感谢你。为了你的帮助。

0 个答案:

没有答案