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

Support for fragment display #4

Closed
chilldelta opened this issue Nov 19, 2015 · 3 comments
Closed

Support for fragment display #4

chilldelta opened this issue Nov 19, 2015 · 3 comments

Comments

@chilldelta
Copy link

Am trying to use this library with my project on fragment but I get a nullpointer error on mAgendaCalendarView.init() which is not the case when I try this on an activity. Am I doing something wrong?
Here is my code

 @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.planner_fragment_ui, container, false);
    ButterKnife.bind(view, getActivity());
    mAgendaCalendarView = new AgendaCalendarView(getContext());

    Calendar minDate = Calendar.getInstance();
    Calendar maxDate = Calendar.getInstance();

    minDate.add(Calendar.MONTH, -2);
    minDate.set(Calendar.DAY_OF_MONTH, 1);
    maxDate.add(Calendar.YEAR, 1);

    List<CalendarEvent> eventList = new ArrayList<>();
    mockList(eventList);
    mAgendaCalendarView.init(eventList, minDate, maxDate, Locale.getDefault(), this);

    return view;
}
@Tibolte
Copy link
Owner

Tibolte commented Nov 19, 2015

@chilldelta When I see your code try: ButterKnife.bind(view, this); (If you do have an AgendaCalendarView element in planner_fragment_ui), and I would also get rid of mAgendaCalendarView = new AgendaCalendarView(getContext());

@chilldelta
Copy link
Author

@Tibolte I fixed the issue without using butterknife by doing
mAgendaCalendarView = (AgendaCalendarView) view.findViewById(R.id.agenda_calender);

@Integrale18
Copy link

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.github.tibolte.agendacalendarview.agenda.AgendaAdapter.updateEvents(java.util.List)' on a null object reference
at com.github.tibolte.agendacalendarview.agenda.AgendaView.lambda$onFinishInflate$8(AgendaView.java:58)

Somebody to help me? i'm using it on Fragment, everything is ok when i use Activity.

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