title: New Activity intent onClick in viewPager Slides
body: <p>Below is my Code.
  Using ViewPager I have made 2 XML file for two Pages and their Class file.</p>
  
  <p>Now I need if I click on First Screen of ViewPager, a new activity should launch.</p>
  
  <p>I got 2 pages, so If I Click First Screen, A.class intent Called. If I click on Second Screen, B.class intent should be Called.</p>
  
  <p>Codes:-</p>
  
  <p>MainActvity:</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
  ViewPager mViewPager;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mViewPager = (ViewPager) findViewById(R.id.pager);
  /** set the adapter for ViewPager */
      mViewPager.setAdapter(new SamplePagerAdapter(
              getSupportFragmentManager()));
  }
  
  /** Defining a FragmentPagerAdapter class for controlling the fragments to       
  be shown when user swipes on the screen. */
  public class SamplePagerAdapter extends FragmentPagerAdapter {
  
      public SamplePagerAdapter(FragmentManager fm) {
          super(fm);
      }
  
      @Override
      public Fragment getItem(int position) {
          /** Show a Fragment based on the position of the current screen */
          if (position == 0) {
              return new SampleFragment();
          } else
              return new SampleFragmentTwo();
      }
  
      @Override
      public int getCount() {
          // Show 2 total pages.
          return 2;
      }
  }
  }
  </code></pre>
  
  <p>SampleFragment.java</p>
  
  <pre><code>public class SampleFragment extends Fragment {
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_one, null);
      return rootView;
      }
      }
  </code></pre>
  
  <p>SampleFragmentTwo.java</p>
  
  <pre><code>public class SampleFragmentTwo extends Fragment {
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_two, container,
              false);
      return rootView;
  }
  }
  </code></pre>
  
  <p>CustomSwipeAdapter:</p>
  
  <pre><code>public class CustomSwipeAdapter extends PagerAdapter {
  
  @Override
  public int getCount() {
      return 0;
  }
  
  @Override
  public boolean isViewFromObject(View view, Object object) {
      return false;
  }
  
  @Override
  public Object instantiateItem(ViewGroup container, int position) {
      return super.instantiateItem(container, position);
  }
  
  @Override
  public void destroyItem(ViewGroup container, int position, Object object) {
      super.destroyItem(container, position, object);
  }
  
  
  }
  </code></pre>