Skip to content Skip to sidebar Skip to footer

Viewpager With Pageradapter Not Working

I'm trying to show images from Drawable in view pager using PagerAdapter for that, I have written below code-- // Call to the PagerAdapter public void showAwardsBadgesAlert()

Solution 1:

First, you should be overriding the instantiateItem() method with ViewGroup as the first parameter, not the one with View as the first parameter. The latter is deprecated.

Then, you need to add your inflated View to the container in the PagerAdapter's instantiateItem() method. Quoting the docs for the instantiateItem() method:

The adapter is responsible for adding the view to the container given here

Simply add container.addView(layout); to the instantiateItem() method, before the return statement.

Solution 2:

((ViewPager) container).addView(layout); Add above statement in your instantiateItem() method, before the return statement. This will surely help you.

Post a Comment for "Viewpager With Pageradapter Not Working"