Skip to content Skip to sidebar Skip to footer

Why Is Calendar In Navigation Drawer Not Working?

The following is my code for my Calendar public class Calender extends android.support.v4.app.Fragment { CalendarView calendar; public Calender() { // Required empty public co

Solution 1:

There is no method getApplicationContext() in Fragment. If you want to get access to local context, write getActivity() instead of getApplicationContext().

Solution 2:

Try

getActivity().getApplicationContext()

instead of only getApplicationContext().

Hope it will help :)

Solution 3:

Toast.makeText(getApplicationContext(), day+ "/" +month+ "/" +year, Toast.LENGTH_LONG).show();

change it to

Toast.makeText(getActivity().getApplicationContext(), day+ "/" +month+ "/" +year, Toast.LENGTH_LONG).show();

to understand why the change is needed, here is the answer.

Solution 4:

Override the fragment method onAttach and store the activity reference to use in entire fragment class.

publicvoidonAttach(Activity activity) {
    super.onAttach(activity);
    mActivity = activity;
}

Post a Comment for "Why Is Calendar In Navigation Drawer Not Working?"