import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import com.example.myapplication.Fragment.HistoryFragment; import com.example.myapplication.Fragment.MineFragment; import com.example.myapplication.Fragment.MsgFragment; /** * @author:created By ZhangHao * 时间:2019/4/24 17 * 邮箱:188660586@qq.com */ public class MainFragmentAdapter extends FragmentPagerAdapter { public MainFragmentAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int i) { Fragment fragment = null; switch (i) { case 0: fragment = new MsgFragment(); break; case 1: fragment = new HistoryFragment(); break; case 2: fragment = new MineFragment(); break; default: break; } return fragment; } @Override public int getCount() { return 3; } }