Reputation: 4639
On Android 6 I get error in CalendarView. I tried find fix for me, but it doesnt help me.
Now my dialog with CalendarView looks like:
And this code from style:
<style name="Widget.CalendarView.Custom" parent="android:Widget.CalendarView">
<item name="android:focusedMonthDateColor">@color/edittext_primary</item>
<item name="android:weekNumberColor">@color/white</item>
<item name="android:selectableItemBackground">@color/edittext_primary</item>
<item name="android:state_focused">@color/edittext_primary</item>
<item name="android:dayOfWeekBackground">@color/edittext_primary</item>
</style>
How to fix it?
Upvotes: 0
Views: 2505
Reputation: 951
This line is causing the issue --
<item name="android:focusedMonthDateColor">@color/edittext_primary</item>
You can try this alternative approach, if it is required.
EDITED SECTION:
According to Android documentation, android:focusedMonthDateColor
,android:weekNumberColor
,android:dayOfWeekBackground
are deprecated in API level 23.
Hence I tried the below approach and I could see the current date is being highlighted in a default way.
String date = "25/2/2016";
String parts[] = date.split("/");
int day = Integer.parseInt(parts[0]);
int month = Integer.parseInt(parts[1]);
int year = Integer.parseInt(parts[2]);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, (month - 1));
calendar.set(Calendar.DAY_OF_MONTH, day);
long milliTime = calendar.getTimeInMillis();
CalendarView calendarView = (CalendarView)findViewById(R.id.cview);
calendarView.setDate(milliTime,true,true);
Hope this will work!
Upvotes: 1