[英]I'm creating a CalendarView, but it takes the previous month instead of the current month?
我正在创建一个 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 { 视图,年,月,dayOfMonth ->
date = dayOfMonth.toString() + "-" + month.toString() + "-" +year.toString() Toast.makeText(activity,date,Toast.LENGTH_SHORT).show() 适配器(date) }
说月份= 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 的月份值,即。 0 表示 1 月 11 日表示 12 月。 所以我们必须在月值中加 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.