How to use PagerAdapter
<p>im trying to use PagerAdapter in my android application but im having difficulty with knowing where to place my code correctly. Its loading the views (xml files) correctly but not sure what code is meant to go were and anywere i have tried just makes the application crash (I know the code works fine because i have it working on standalone pages) - ive been on the android development page but its not very clear to me. Many thanks (sorry if its a stupid question but no idea)</p>

<p>pivate class MyPagerAdapter extends PagerAdapter 
{</p>

<pre><code>   public int getCount() 
   {
        return 3;
   }

    public Object instantiateItem(View collection, int position) 
    {
            LayoutInflater inflater = (LayoutInflater) collection.getContext()
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            int resId = 0;
            switch (position) 
            {
            case 0:
                    resId = R.layout.left;
                    break;
            case 1:
                    resId = R.layout.middle;
                    break;
            case 2:
                    resId = R.layout.right;
                    break;
            }
            View view = inflater.inflate(resId, null);
            ((ViewPager) collection).addView(view, 0);
            return view;
    }
    @Override
    public void destroyItem(View arg0, int arg1, Object arg2) 
    {
            ((ViewPager) arg0).removeView((View) arg2);
    }
    @Override
    public void finishUpdate(View arg0) 
    {
            // TODO Auto-generated method stub
    }
    @Override
    public boolean isViewFromObject(View arg0, Object arg1) 
    {
            return arg0 == ((View) arg1);
    }
    @Override
    public void startUpdate(View arg0) 
    {
            // TODO Auto-generated method stub
    }
</code></pre>

<p>}</p>
