forum

Home / DeveloperSection / Forums / Android ViewPager having same instance every time

Android ViewPager having same instance every time

Anonymous User179330-Oct-2015
I have a viewPager with for 10 pages. In all of theses pages, I have a YouTubePlayer with a different id video.
The problem is that all the YouTubePlayer component has the same video at the same time.

Concretely :
When the first page is displayed, the YouTubePlayer show the first video, so all seems to be ok. When I try to scroll to the 2nd page, I can see that the 2nd YouTubePlayer show the same video. When the 2nd page is completely displayed (After scrolling), behind the view pager prepare the 3rd page. So on the 3rd page the 3rd id video is set to the YouTubePlayer component. At that moment the 2nd page currently displayed switch automatically to the 3rd video.

It was like if the instance of YouTubePlayer was single for all the pages. But on each page new FragmentYouTubePlayer() is correctly called.

I don't understand where is the problem. Finally, I wonder if it's possible to use severals YouTubePlayer component (in a viewpager) at the same time or not ?

Updated on 30-Oct-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By