I am writing an PageViewer
implementation using FragmentPagerAdapter
.
Fragment child uses Activity reference in onViewCreated(..){}
which is get from onAttach(Activity activity){}
private ScreenSlideActivity parentActivity = null;
@Override public void onAttach(Activity activity) {
super.onAttach(activity);
parentActivity = (SlideActivity) parentActivity;
}
Now I am trying to use this parentActivity Object in onViewCreated() which is returning me null.
Any suggestion if I am missing anything while maintaining ViewPager behaviour?
You're assigning a variable into itself which doesn't really change anything. A null will remain null.
You probably wanted: