Fragment页面切换

private void initData() {
    ArrayList strings = new ArrayList<>();//调全局
    strings.add("列表");
    strings.add("收藏");
    ArrayList fragments = new ArrayList<>();//调全局
    fragments.add(new AFragment());
    fragments.add(new BFragment());
    MyAdapter myAdapter = new MyAdapter(getSupportFragmentManager(), strings, fragments);
    vp.setAdapter(myAdapter);
    tab.setupWithViewPager(vp);

}

你可能感兴趣的:(Fragment页面切换)