Error:(36, 74) error: incompatible types: Fragment cannot be converted to Context

后端 未结 3 614

I have a fragment called CalendarFragment. I am getting this error when i tried executing the program. Error:(36, 74) error: incompatible types: CalendarFragment cannot be conve

3条回答
  •  滥情空心
    2021-01-26 05:01

    I suppose your error is indicating the line CalendarEventDataSource dataSource = new CalendarEventDataSource(this);

    Try and change this with either getActivity() or getActivity().getApplicationContext() or getActivity().getBaseContext().

    Also no need for onCreate() as other have suggested.

提交回复
热议问题