title: Start new activity with PageAdapter
body: <p>I am developing an android app, in which there are 4 different tabs. Now with each tab, I've to assign different activity. e.g. Say with tab 1, there should be First.java activity. With tab 2, there should be Second.java activity and so on. I've followed one tutorial and implemented successfully, below is my code,</p>
  
  <h2>activity_main.xml</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@android:id/tabhost"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical" &gt;
  
          &lt;TabWidget
              android:id="@android:id/tabs"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content" /&gt;
  
          &lt;FrameLayout
              android:id="@android:id/tabcontent"
              android:layout_width="match_parent"
              android:layout_height="match_parent" &gt;
  
              &lt;FrameLayout
                  android:id="@+id/tab1"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:visibility="gone" /&gt;
  
              &lt;FrameLayout
                  android:id="@+id/tab2"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:visibility="gone" /&gt;
  
              &lt;FrameLayout
                  android:id="@+id/tab3"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:visibility="gone" /&gt;
  
              &lt;FrameLayout
                  android:id="@+id/tab4"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:visibility="gone" /&gt;
          &lt;/FrameLayout&gt;
  
          &lt;android.support.v4.view.ViewPager
              xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/pager"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/TabHost&gt;
  </code></pre>
  
  <h2>MainActivity.java</h2>
  
  <pre><code>public class MainActivity extends Activity implements OnTabChangeListener, OnPageChangeListener{  
      private TabHost host;  
      private ViewPager pager; 
  
   @Override  
   public void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_main);  
     host = (TabHost)findViewById(android.R.id.tabhost);  
     pager = (ViewPager) findViewById(R.id.pager);  
  
     host.setup();  
  
  
     TabSpec spec = host.newTabSpec("tab1");  
     spec.setContent(R.id.tab1);  
     spec.setIndicator("Check In");   
     host.addTab(spec);  
  
     spec = host.newTabSpec("tab2");  
     spec.setContent(R.id.tab2);  
     spec.setIndicator("Buddies");  
     host.addTab(spec);  
  
     spec = host.newTabSpec("tab3");  
     spec.setContent(R.id.tab3);  
     spec.setIndicator("Recommendation");  
     host.addTab(spec); 
  
     spec = host.newTabSpec("tab4");  
     spec.setContent(R.id.tab4);  
     spec.setIndicator("Feed");  
     host.addTab(spec);  
  
     pager.setAdapter(new MyPagerAdapter(this));  
     pager.setOnPageChangeListener(this);  
     host.setOnTabChangedListener(this);  
  
   }  
      @Override  
      public void onTabChanged(String tabId){  
           int pageNumber = 0;  
           if(tabId.equals("tab1"))
           {  
                pageNumber = 0;  
  
           }
  
           else if(tabId.equals("tab2"))
           {  
                pageNumber = 1;  
           }
  
           else if(tabId.equals("tab3"))
           {  
                pageNumber = 2;  
           }
  
           else if(tabId.equals("tab4"))
           {  
                pageNumber = 3;  
           }
           else
           {  
                pageNumber = 3;  
           }  
  
           pager.setCurrentItem(pageNumber);  
      } 
  
      @Override  
      public void onPageSelected(int pageNumber) {  
           host.setCurrentTab(pageNumber);  
      }
      @Override
      public void onPageScrollStateChanged(int arg0) {
  
  
      }
      @Override
      public void onPageScrolled(int arg0, float arg1, int arg2) {
  
  
      }
      }
  </code></pre>
  
  <h2>MyPagerAdapter.java</h2>
  
  <pre><code>public class MyPagerAdapter extends PagerAdapter {
      private Context ctx;
  
      public MyPagerAdapter(Context ctx) {
          this.ctx = ctx;
      }
  
      @Override
      public Object instantiateItem(ViewGroup container, int position) {
          TextView tView = new TextView(ctx);
          position++;
          tView.setText("Page number: " + position);
          tView.setTextColor(Color.RED);
          tView.setTextSize(20);
          container.addView(tView);
          return tView;
      }
  
      @Override
      public int getCount() {
          return 4;
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
          return (view == object);
      }
  
      @Override
      public void destroyItem(View container, int position, Object object) {
          ((ViewPager) container).removeView((View) object);
      }
  }
  </code></pre>
  
  <p>But, here I want to start different activity with each tab, how can I do that?</p>