I have an activity holding a fragment, in this fragment there is a button , when it is clicked, a dialog is popped out.
In this dialog, there is a Viewpager, which
Try using DialogFragment and pass getChildFragmentManager() to your FragmentPagerAdapter's constructor.
DialogFragment:
public static class MyDialogFragment extends DialogFragment {
private ViewPager viewPager;
MySectionPagerAdapter mAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.m_layout, container);
viewPager = (ViewPager) view.findViewById(R.id.viewpager);
mAdapter = new MySectionPagerAdapter(getChildFragmentManager());
viewPager.setAdapter(mAdapter);
return view;
}
}
I found in Google a blog post, it says that viewpager doesn't work on Dialog. It also says we should use DialogFragment instead.
Here is the link to that blog: http://www.intellicode.in/viewpager-inside-dialog/