Cover Chart:
Demo Effect Chart
SOURCE directory Structure
Features
- Slide the calendar around.
- Displays Gregorian calendar, lunar calendar, holidays and Shiber
- Implement a single or multiple selection of a month's date.
Use steps
Gradle Dependency
ADD the library to your project Build.gradle
Compile ' com.joybar.calendar:librarycalendar:1.0.4 '
Sample Usage
Implement Onpagechangelistener and Ondateclicklistener interface, if you implement multiple selections, you need to implement Ondatecancellistener
public class Mainactivity extends Appcompatactivity implements Calendarviewpagerfragment.onpagechangelistener, Calen
Darviewfragment.ondateclicklistener, Calendarviewfragment.ondatecancellistener {private TextView tv_date;
Private Boolean ischoicemodelsingle = false;
Private list<calendardate> mlistdate = new arraylist<> ();
@Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Tv_date = (TextView) Findviewbyid (r.id.tv_date);
Initfragment ();
private void Initfragment () {Fragmentmanager fm = Getsupportfragmentmanager ();
Fragmenttransaction tx = Fm.begintransaction ();
Fragment Fragment = new Calendarviewpagerfragment ();
Fragment Fragment = calendarviewpagerfragment.newinstance (Ischoicemodelsingle);
Tx.replace (r.id.fl_content, fragment);
Tx.commit (); @Override public boolean Oncreateoptionsmenu (Menu menu) {getmenuinflater (). Inflate (R.menu.menu_im, menu);
return true; @Override public boolean onoptionsitemselected (MenuItem item) {switch (Item.getitemid ()) {case r.id.menu_sing
Le:ischoicemodelsingle = true;
Initfragment ();
Break
Case r.id.menu_multi:ischoicemodelsingle = false;
Initfragment ();
Break
Default:break;
return true;
@Override public void Ondateclick (Calendardate calendardate) {int year = Calendardate.getsolar (). Solaryear;
int month = Calendardate.getsolar (). Solarmonth;
int day = Calendardate.getsolar (). Solarday;
if (ischoicemodelsingle) {Tv_date.settext (year + "-" + month + "-" + day);
else {//system.out.println (Calendardate.getsolar (). Solarday);
Mlistdate.add (calendardate);
Tv_date.settext (listtostring (mlistdate));
@Override public void Ondatecancel (Calendardate calendardate) {int count = Mlistdate.size (); for (int i = 0; i < count; i++) {Calendardate date = Mlistdate.get (i);
if (Date.getsolar (). Solarday = = Calendardate.getsolar (). Solarday) {mlistdate.remove (i);
Break
} tv_date.settext (Listtostring (mlistdate));
@Override public void Onpagechange (int year, int month) {Tv_date.settext (year + "-" + month);
Mlistdate.clear (); private static String listtostring (list<calendardate> List) {StringBuffer stringbuffer = new StringBuffer (
); for (Calendardate date:list) {stringbuffer.append (Date.getsolar (). Solaryear + "-" + date.getsolar (). SolarMonth + "-"
+ Date.getsolar (). Solarday). Append ("");
return stringbuffer.tostring ();
}
}
Single or multiple-selected implementation code
if (ischoicemodelsingle) {mgridview.setchoicemode (gridview.choice_mode_single);
else {mgridview.setchoicemode (gridview.choice_mode_multiple); Mgridview.setonitemclicklistener (New Adapterview.onitemclicklistener () {@Override public void Onitemclick (Adapt Erview<?> Parent, view view, int position, long id) {Calendardate calendardate = ((calendargridviewadapter) Mgri
Dview.getadapter ()). Getlistdata (). get (position); if (ischoicemodelsingle) {//Radio if (finalmlistdatacalendar.get (position). Isinthismonth ()) {Ondateclicklistene
R.ondateclick (calendardate);
else {mgridview.setitemchecked (position, false); } else {//multiple-Select if (Finalmlistdatacalendar.get (position). Isinthismonth ()) {//Mgridview.getcheckeditemids (
) if (!mgridview.isitemchecked (position)) {ondatecancellistener.ondatecancel (calendardate);
else {Ondateclicklistener.ondateclick (calendardate); } else {MGRIDVIEW.SETITEMCHecked (position, false);
}
}
}
});
Git address: Https://github.com/myjoybar/android-calendar-view
The above is the Android Calendar control data collation, follow-up continue to supplement the relevant information, thank you for your support of this site!