android - Only display current month's days in Caldroid -
i using caldroid library app, , have ran issue.
i want current month's dates show on calendar.
i have looked through caldroid documentation, not find anything.
i know can set max date calendar, couldn't find setting max/min each month.
hope out :)
i had same issue , made that.
create new selector in drawable example calendar_cell_text_color.xml. in file put sth this.
<!-- caldroid days prev , next month --> <item android:color="@color/white" caldroid:state_date_prev_next_month="true"/> <!-- caldroid days current month --> <item android:color="@color/black" />
now, have change style of caldroiddefaultcell .
in file style.xml add follows line.
<!-- caldroid theme. --> <style name="mycaldroid" parent="caldroiddefault"> <!--if use compact view in caldroid --> <item name="stylecaldroidnormalcell">@style/caldroidcell</item> <!-- if use square (default) view in caldroid--> <item name="stylecaldroidsquarecell">@style/caldroidcell</item> </style> <style name="caldroidcell" parent="caldroiddefaultcell"> <item name="android:textcolor">@drawable/calendar_cell_text_color</item> </style>
now need add line use yout theme after initizalized caldroid.
caldroidfragment = new caldroidfragment(); caldroidfragment.setthemeresource(r.style.mycaldroid);
now dates other months not visible, still can click on them. im working figure out how disable them.
edit :
if want disable dates
//date argument current month visible on screen public void disableprevnextmonthday(date date){ disabledates.settime(date); // disabledates calendar object disabledates.set(calendar.day_of_month, 1); // 1st day of current month caldroidfragment.setmindate(disabledates.gettime()); int maxday = disabledates.getactualmaximum(calendar.day_of_month); disabledates.set(calendar.day_of_month, maxday); caldroidfragment.setmaxdate(disabledates.gettime()); //last day of current month }
and call method in onchangemonth() method caldroid.
if add selector state_date_disabled in file similar calendar_cell_text_color.xml , set background white in previous example text color have invisible non clicked dates.
Comments
Post a Comment