VideoView within a ViewPager
<p>My main activity layout consists of a ViewPager.
This ViewPager has various pages in it and they are inflated through a set of XML layout files.</p>

<p>One of the XML layout file I have has a VideoView in it.
How do I initialize this VideoView in it? </p>

<p>This is the onCreate method of the Activity. I cannot initialize the VideoView as it has not been inflated by the ViewPagerAdapter. </p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);      

    ViewPagerAdapter adapter = new ViewPagerAdapter(this);
    ViewPager pager = (ViewPager) findViewById(R.id.viewpager);
    TitlePageIndicator indicator = (TitlePageIndicator) findViewById(R.id.indicator);
    pager.setAdapter(adapter);
    indicator.setViewPager(pager);

// mVideoView is null.. where should I init this?   
    VideoView mVideoView = (VideoView) findViewById(R.id.myvideoview);
    mVideoView.setVideoPath(path);
    mVideoView.setMediaController(new MediaController(this)); 
    mVideoView.start();

}
</code></pre>

<p>This is the instantiateItem method in the ViewPagerAdapter.</p>

<pre><code>public Object instantiateItem( View pager, int position )
{
    //Inflate the correct layout
    LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    //layouts[] is an int[] that points to resources such as R.layout.start_page
    View inflatedView = layoutInflater.inflate(layouts[position], null);

    ((ViewPager)pager).addView(inflatedView,0);

    // is this the correct way to do this?
    if (position == 1) {
        VideoView mVideoView = (VideoView) inflatedView.findViewById(R.id.myvideoview);
        mVideoView.setVideoPath(path);
        mVideoView.start();
    }
    return inflatedView;

}
</code></pre>

<p>I think it should be initialised in here?</p>
