nomanr / WeekCalendar

A simple weekly calendar.
646 stars 128 forks source link

invisible day number #6

Open SaraAshourHelmy opened 8 years ago

SaraAshourHelmy commented 8 years ago

when open another fragment then back to fragment that contain calendar found the day number invisible must swipe to view again ???

nomanr commented 8 years ago

Could you please share the code where using the calendar. One know issue could me inside fragment where you are using getActivity().getSupportFragment() , replace it will getChildFragmentManager() .

And it is not Calendars issue, Calendar contains fragment and you are using a fragment inside a fragment.

SaraAshourHelmy commented 8 years ago

i am using tabhost and this tabs contains fragments when press to fragment that contain calendar execute this method firt :+1:

private void SetupCalendar() {

    selected_date = Calendar.getInstance();
    updated_date = Calendar.getInstance();
    txtDate_format = new SimpleDateFormat("EEEE MMMM dd, yyyy");
    date_format = new SimpleDateFormat("yyyy-MM-dd");

    // set current date
    // Note calendar start month index from 0 so month number will be -1
    Calendar c = Calendar.getInstance();
    selected_year = c.get(Calendar.YEAR);
    selected_month = c.get(Calendar.MONTH);
    selected_day = c.get(Calendar.DAY_OF_MONTH);

    // set current date in Textview
    String folderName = txtDate_format.format(c.getTime());
    tv_selected_date.setText(folderName);
    tv_selected_date.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ShowCalendar();
        }
    });

    // when click on swipe calendar
    weekCalendar.setOnDateClickListener(new OnDateClickListener() {
        @Override
        public void onDateClick(DateTime dateTime) {

            selected_date.set(Calendar.YEAR, dateTime.getYear());
            selected_date.set(Calendar.MONTH, dateTime.getMonthOfYear());
            selected_date.set(Calendar.DAY_OF_MONTH, dateTime.getDayOfMonth());

            selected_year = dateTime.getYear();
            selected_month = dateTime.getMonthOfYear() - 1;
            selected_day = dateTime.getDayOfMonth();

            try {
                Date folderName1 = date_format.parse(dateTime.toString());
                Log.e("selected_date", selected_date + "");

                tv_selected_date.setText(txtDate_format.format(folderName1));
            } catch (Exception e) {
                Log.e("date error", "" + e);
            }
        }

    });

}
alexarraiza commented 8 years ago

I get the same problem whenever I put more than one WeekCalendar on a fragment, e.g., I have an adapter where some items contain two WeekCalendars, but only the first one of the whole screen loads the days.

Is this a known issue or is there a limit of how many calendars can you load on the same fragment/activity?

Thank you, if I find anything else that relates to this problem I'll update you!

Edit: When having multiple fragments, each with a calendar, when the one that is showing the days is garbage collected, the next one that loads will be the one that show days.

samarti commented 8 years ago

+1, same here!

erichlotto commented 8 years ago

+1 same here!

HugoMartins commented 8 years ago

+1 same here!