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
A Fragment represents a behavior or a portion of user interface in an Activity.
Call onCreateView instead of onCreate. Remove onCreate()
call getActivity() instead of this. getActivity() Return the Activity this fragment is currently associated with.
CalendarEventDataSource dataSource = new CalendarEventDataSource(getActivity());
Problem
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_calendar);
}
This code for Activity . You should use your onCreateView method .
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.fragment_calendar, container, false);
return rootView;
}
http://developer.android.com/intl/es/guide/components/fragments.html