Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Marker in Calendar using Connected Days for events, task, note, etc. #93

Open
abdulrahmankazi opened this issue May 27, 2021 · 3 comments

Comments

@abdulrahmankazi
Copy link

abdulrahmankazi commented May 27, 2021

### SOLUTION TO ADD EVENTS

Screenshot_1622012396

I was searching for a way to add marker on particular dates, but didn't find any.
However as you can see in above image, I have managed to add marker to Calendar dates.
I have used addConnectedDays() provided by Cosmo Calendar.
Markers can be added on TOP & BOTTOM of date.
Sharing code I used:

                    Set<Long> days = new TreeSet<>();
                    e.g. 
                    String date1 = "05-18-2021";
                    String date2 = "05-09-2021";
                    //........

                    SimpleDateFormat sdf1 = new SimpleDateFormat("MM-dd-yyyy");
                    try {
                        Date mDate1 = sdf1.parse(date1);
                        long timeInMilliseconds1 = mDate1.getTime();

                        
                        Date mDate2 = sdf1.parse(date2);
                        long timeInMilliseconds2 = mDate2.getTime();

                        days.add(timeInMilliseconds1);
                        days.add(timeInMilliseconds2);
                        // can add more days to set

                    } catch (Exception e) {
                        Log.e("DateException", e.getMessage());
                    }
          
                int textColor = Color.parseColor("#0063B0");
                int selectedTextColor = Color.parseColor("#FFFFFF");
                int disabledTextColor = Color.parseColor("#ff8000");
                ConnectedDays connectedDays = new ConnectedDays(days, textColor, selectedTextColor, disabledTextColor);

                //Add Connect days to calendar
                calendarView.addConnectedDays(connectedDays);

                calendarView.setConnectedDayIconRes(R.drawable.ic_baseline_star_24);   // Drawable
                calendarView.setConnectedDayIconPosition(ConnectedDayIconPosition.TOP);// TOP & BOTTOM
                calendarView.update();
@sourav-android
Copy link

the calendar keeps to the current month, how do I stop this ?

@TakJIAe
Copy link

TakJIAe commented Apr 1, 2022

Thanks for providing the solution. I want multiple markers for that date to be created, do you know how?

@abdulrahmankazi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants