Use more views in viewpages
<p>How can I use different views in the viewpages? I cant figure it out. </p>

<p>For example a view with listbox and a view with buttons.</p>

<p>This is my code:</p>

<p>How can I use different views in the viewpages? I cant figure it out. </p>

<p>For example a view with listbox and a view with buttons.</p>

<p>This is my code:</p>

<pre><code>package com.stylingandroid.viewpager;

import com.viewpagerindicator.TitlePageIndicator;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.ViewPager;

public class ViewPagerActivity extends Activity
{
    /** Called when the activity is first created. */
    @Override
    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);
    }
}
</code></pre>

<p>And here the adapter:</p>

<pre><code>package com.stylingandroid.viewpager;

import android.content.Context;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.viewpagerindicator.TitleProvider;

public class ViewPagerAdapter extends PagerAdapter
    implements TitleProvider
{
    private static String[] titles = new String[]
    {
        "Page 1",
        "Page 2",
        "Page 3"
    };
    private final Context context;

    public ViewPagerAdapter( Context context )
    {
        this.context = context;
    }

    @Override
    public String getTitle( int position )
    {
        return titles[ position ];
    }

    @Override
    public int getCount()
    {
        return titles.length;
    }

    @Override
    public Object instantiateItem( View pager, int position )
    {
        TextView v = new TextView( context );
        v.setText(titles[position]);

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

        return v;
    }

    @Override
    public void destroyItem( View pager, int position, Object view )
    {
        ((ViewPager)pager).removeView( (TextView)view );
    }

    @Override
    public boolean isViewFromObject( View view, Object object )
    {
        return view.equals( object );
    }

    @Override
    public void finishUpdate( View view ) {}

    @Override
    public void restoreState( Parcelable p, ClassLoader c ) {}

    @Override
    public Parcelable saveState() {
        return null;
    }

    @Override
    public void startUpdate( View view ) {}
}
</code></pre>
