I am having trouble creating and adding a view pager programmatically.
I have found this question Android create ViewPager programmatically but the accepted answer doesnt work for me.
Here is the relative code.
ImagesPagerAdapter mImagePagerAdapter = new ImagesPagerAdapter(getActivity(), mProduct.getImages());
ViewPager mImagePager = (ViewPager) inflater.inflate(R.layout.partial_view_pager, null);
mImagePager.setAdapter(mImagePagerAdapter);
rootView.add(mImagePager);
I have also tried modifying the second line to but no effect:
ViewPager mImagePager = new ViewPager(getActivity());
The view pager just doesnt show up in the rendered layout. If i debug i can see that it instantiates the views but they just dont show. I have tried adding the id like suggested in the solution and also setting the id in layout partial_view_layout.
The only thing that seems to work is if i add the view pager through xml directly in the layout. This is not an option for me, since i want to be able to add multiple view pagers to the same layout.
Any ideas?