Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java I';我正在创建一个日历视图,但它使用的是上个月而不是当前月份?_Java_Android_Kotlin - Fatal编程技术网

Java I';我正在创建一个日历视图,但它使用的是上个月而不是当前月份?

Java I';我正在创建一个日历视图,但它使用的是上个月而不是当前月份?,java,android,kotlin,Java,Android,Kotlin,我正在创建CalendarView,但它使用上一个月而不是当前月份。 救救我 <CalendarView android:id="@+id/calendarView" android:layout_width="0dp" android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="parent&quo

我正在创建CalendarView,但它使用上一个月而不是当前月份。 救救我

    <CalendarView
    android:id="@+id/calendarView"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/radioGup" />

calendarView.setOnDateChangeListener {查看、年、月、月的日期->

date=dayOfMonth.toString()+“-”+月.toString()+“-”+年.toString() Toast.makeText(活动、日期、Toast.LENGTH_SHORT).show() 适配器(日期) }

表示月份=1

/**
         * Called upon change of the selected day.
         *
         * @param view The view associated with this listener.
         * @param year The year that was set.
         * @param month The month that was set [0-11].
         * @param dayOfMonth The day of the month that was set.
         */
        void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth);
这将返回0到11的月值,即1月11日12月的月值为0。 所以我们必须在月值中加1

这将返回0到11的月值,即1月11日12月的月值为0。
因此,我们必须在月内增加1个值

您是如何实现的?请出示代码不,我不知道,所有的kotlinHow你实现了吗?如果月亮=11,我们加1,难道不是12吗?因为我们认为一月是第一个月,十一月是第十一个月。所以十二月肯定是第12个月。现在,此CalendarView返回范围为0到11的月份值。为了得到实际的月份值,我们必须增加一个非常非常感谢的如果月亮是11,我们加1,它不能是12吗?因为我们把一月作为第一个月和十一月作为第十一个月。所以十二月肯定是第12个月。现在,此CalendarView返回范围为0到11的月份值。因此,为了得到实际的月份值,我们必须加上1