Search in sources :

Example 1 with OneFragment

use of com.example.jingbin.cloudreader.ui.one.OneFragment in project CloudReader by youlookwhat.

the class MainActivity method initContentFragment.

private void initContentFragment() {
    ArrayList<Fragment> mFragmentList = new ArrayList<>();
    mFragmentList.add(new GankFragment());
    mFragmentList.add(new OneFragment());
    mFragmentList.add(new BookFragment());
    // 注意使用的是:getSupportFragmentManager
    MyFragmentPagerAdapter adapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), mFragmentList);
    vpContent.setAdapter(adapter);
    // 设置ViewPager最大缓存的页面个数(cpu消耗少)
    vpContent.setOffscreenPageLimit(2);
    vpContent.addOnPageChangeListener(this);
    mBinding.include.ivTitleGank.setSelected(true);
    vpContent.setCurrentItem(0);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        //去除默认Title显示
        actionBar.setDisplayShowTitleEnabled(false);
    }
}
Also used : GankFragment(com.example.jingbin.cloudreader.ui.gank.GankFragment) MyFragmentPagerAdapter(com.example.jingbin.cloudreader.view.MyFragmentPagerAdapter) ArrayList(java.util.ArrayList) OneFragment(com.example.jingbin.cloudreader.ui.one.OneFragment) BookFragment(com.example.jingbin.cloudreader.ui.book.BookFragment) GankFragment(com.example.jingbin.cloudreader.ui.gank.GankFragment) BookFragment(com.example.jingbin.cloudreader.ui.book.BookFragment) Fragment(android.support.v4.app.Fragment) OneFragment(com.example.jingbin.cloudreader.ui.one.OneFragment) ActionBar(android.support.v7.app.ActionBar)

Aggregations

Fragment (android.support.v4.app.Fragment)1 ActionBar (android.support.v7.app.ActionBar)1 BookFragment (com.example.jingbin.cloudreader.ui.book.BookFragment)1 GankFragment (com.example.jingbin.cloudreader.ui.gank.GankFragment)1 OneFragment (com.example.jingbin.cloudreader.ui.one.OneFragment)1 MyFragmentPagerAdapter (com.example.jingbin.cloudreader.view.MyFragmentPagerAdapter)1 ArrayList (java.util.ArrayList)1