simpleCalendarView.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="info.androidhive.materialtabs.fragments.EightFragment"
>
<CalendarView
android:id="@+id/simpleCalendarView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
CalendarFragment.class
public class CalendarFragment extends Fragment {
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_eight, container, false);
CalendarView calendarView = (CalendarView) rootView.findViewById(R.id.simpleCalendarView);
calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(@NonNull CalendarView calendarView, int year, int month,
int dayOfMonth) {
Toast.makeText(getActivity(), year + "" + month + "" + dayOfMonth, Toast.LENGTH_LONG)
.show();// TODO Auto-generated method stub
}
});
return rootView;
}
}
这是我使用此代码给出的我能够显示日历并且能够应用点击功能但我希望在某个给定日期显示红色,绿色我只是想知道我们可以用CalendarView做下面是我的预期屏幕请建议如果我们能做到这一点,请告诉我如何做到这一点。