Each time I swipe there will be a new page loaded now I had everything working in portrait first and now I am trying to get it working with landscape and portrait. But when I rotate my screen I will get a NullPointerException
on my Dialog
.
The function causing it inside MainActivity
's innerclass FragmentStatePagerAdapter
:
@Override
public void onPageSelected(int position)
{
// TODO Auto-generated method stub
currentSelectedFragmentPosition = position;
frag.onPageVisible(currentSelectedFragmentPosition);
frag2.onPageVisible(currentSelectedFragmentPosition);
frag3.onPageVisible(currentSelectedFragmentPosition);
}
The function inside the fragment :
public void onPageVisible(int position)
{
startNewAsyncTask();
}
The dialog is instantiated inside the onCreateView
and logs back that it is not null.
When I log inside onPageVisible
it does log back null and when I do
mProgress = new ProgressDialog(getActivity());
inside the onPageVisible
it will still give a nullpointer but then on that line instead.
I really don't understand why it should be set in the onCreateView
.