我想在CardView上展示一个特定的月份,而不需要使用“下一个”和“上一个”箭头来导航日历。如果我想要展示2010年2月,用户只能看到2010年2月,他们无法查看前一个或后一个月份。
我按照这个Stack Overflow答案来展示特定的月份,但对我并没有起作用。它每次都显示当前日期和月份,对于我的情况,我不确定是否可能禁用“下一个”和“上一个”导航。
我的XML:
我按照这个Stack Overflow答案来展示特定的月份,但对我并没有起作用。它每次都显示当前日期和月份,对于我的情况,我不确定是否可能禁用“下一个”和“上一个”导航。
我的XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="megaminds.dailyeditorialword.Fragments.CalendarViewFragment">
<CalendarView
android:id="@+id/calendarViewT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:firstDayOfWeek="7">
</CalendarView>
我的fragment类的onCreateView
方法:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_calendar_view, container, false);
int year = 2010, month = 2, day = 1;
CalendarView calendarView = (CalendarView) view.findViewById(R.id.calendarViewT);
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, day); //want to show full month of February 2010
calendarView.setMinDate(calendar.getTimeInMillis());
return view;
}
如何只显示二月份而不带有前后导航?
setDate()
请求的日期。“我能禁用它吗?”--据我所知,不能,因为CalendarView
的目的是让用户选择日期。也许正确的答案是您不应该使用CalendarView
,而是使用一些更符合您所需功能集的库。 - CommonsWare