title: android : change tab and pager with button event in pager slidding tab strip
body: <p>i use pager sliding tab strip in my app , i want to change tab and pager with button event how can i do that ? 
  i use this code but it`s not work </p>
  
  <pre><code>public class CheckoutMethod_Fragment extends Fragment {
  
  private static final String ARG_POSITION = "position";
  
  private int position;
  private Button btn_continue;
  ViewPager pager;
  
  
  public static CheckoutMethod_Fragment newInstance(int position) {
      CheckoutMethod_Fragment f = new CheckoutMethod_Fragment();
      Bundle b = new Bundle();
      b.putInt(ARG_POSITION, position);
      f.setArguments(b);
      return f;
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      position = getArguments().getInt(ARG_POSITION); 
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
      final View v = inflater.inflate(R.layout.activity_checkout_method__fragment,
              container, false);
  
      final ViewPager pager = (ViewPager) v.findViewById(R.id.pager);
      pager.setAdapter(new ViewPagerAdapter_PlaceCartOrder(getFragmentManager()));
  
      btn_continue = (Button) v.findViewById(R.id.button_continue);
      btn_continue.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View view) {
              // TODO Auto-generated method stub
              //Replace right fragment with another fragment
  
              pager.setCurrentItem(2);
          }
      });
      return v;
  }}
  </code></pre>
  
  <hr>
  
  <p>and this is ViewPagerAdapter_PlaceCartOrder </p>
  
  <pre><code>public class ViewPagerAdapter_PlaceCartOrder extends FragmentPagerAdapter {
  
  private final String[] TITLES = { "Checkout Method","bbbb", "aaa ","ggg", "Order Review" };
  
  public ViewPagerAdapter_PlaceCartOrder(FragmentManager fm) {
      super(fm);
  }
  
  @Override
  public CharSequence getPageTitle(int position) {
      return TITLES[position];
  }
  
  @Override
  public int getCount() {
      return TITLES.length;
  }
  
  @Override
  public Fragment getItem(int position) {
  
      switch (position) {
  
      case 0:
          return CheckoutMethod_Fragment.newInstance(position);
      case 1:
          return CustomerInformation_Fragment.newInstance(position);
      case 2:
          return BillingInformation_Fragment.newInstance(position);
      case 3:
          return ShippingInformation_Fragment.newInstance(position);
      case 4:
          return ShippingMethod_Fragment.newInstance(position);
      case 5:
          return PaymentInformation_Fragment.newInstance(position);
      case 6:
          return OrderReview_Fragment.newInstance(position);
      case 7:
          return CheckoutMethod_Fragment.newInstance(position);
      case 8:
          return CheckoutMethod_Fragment.newInstance(position);
      case 9:
          return CheckoutMethod_Fragment.newInstance(position);
      default:
          return SuperAwesomeCardFragment.newInstance(6000);
      }
  
      // return SuperAwesomeCardFragment.newInstance(position);
  }}
  </code></pre>
  
  <hr>
  
  <pre><code>public class PlaceOrderActivity extends FragmentActivity {
  
  ViewPager pager;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_place_order);
  
      Typeface typeface = Typeface.createFromAsset(getAssets(),
              "fonts/Yekan.ttf");
  
      // Initialize the ViewPager and set an adapter
      pager = (ViewPager) findViewById(R.id.pager);
      pager.setAdapter(new ViewPagerAdapter_PlaceCartOrder(getSupportFragmentManager()));
      //pager.setCurrentItem(7);
  
      // Bind the tabs to the ViewPager
      PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
      tabs.setViewPager(pager);
      tabs.setIndicatorColor(Color.rgb(225, 19, 18));
      tabs.setIndicatorHeight(3);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      //getMenuInflater().inflate(R.menu.place_order, menu);
      return true;
  }
  
  public void ChangeFragment(){
      pager.setCurrentItem(2);
  }}
  </code></pre>