content: package com.handsome.didi.Activity.Home;
  
  import android.support.design.widget.TabLayout;
  import android.support.v4.app.Fragment;
  import android.support.v4.view.ViewPager;
  import android.view.View;
  import android.widget.Button;
  
  import com.handsome.didi.Adapter.Main.MainAdapter;
  import com.handsome.didi.Base.BaseActivity;
  import com.handsome.didi.Fragment.Home.RechargeGameFragment;
  import com.handsome.didi.Fragment.Home.RechargePhoneFragment;
  import com.handsome.didi.R;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class RechargeActivity extends BaseActivity {
  
      private TabLayout tl_recharge;
      private ViewPager vp_recharge;
      private List<Fragment> fragments;
      private List<String> strings;
      private MainAdapter adapter;
      private Button bt_charge;
  
      @Override
      public int getLayoutId() {
          return R.layout.activity_recharge;
      }
  
      @Override
      public void initViews() {
          tl_recharge = findView(R.id.tl_recharge);
          vp_recharge = findView(R.id.vp_recharge);
          bt_charge = findView(R.id.bt_charge);
      }
  
      @Override
      public void initListener() {
          setOnClick(bt_charge);
      }
  
      @Override
      public void initData() {
          setTitle("充值中心");
          setTitleCanBack();
  
          initFragments();
      }
  
      @Override
      public void processClick(View v) {
          switch (v.getId()) {
              case R.id.bt_charge:
                  showToast("功能未开启");
                  break;
          }
      }
  
      private void initFragments() {
          fragments = new ArrayList<>();
          fragments.add(new RechargePhoneFragment());
          fragments.add(new RechargeGameFragment());
  
          strings = new ArrayList<>();
          strings.add("话费充值");
          strings.add("点卡点券");
          //添加Tab
          for (String str : strings) {
              tl_recharge.addTab(tl_recharge.newTab().setText(str));
          }
          //绑定ViewPager
          adapter = new MainAdapter(getSupportFragmentManager(), fragments, strings);
          vp_recharge.setAdapter(adapter);
          vp_recharge.setOffscreenPageLimit(2);
          tl_recharge.setupWithViewPager(vp_recharge);
      }
  
  }
  