Search in sources :

Example 1 with DiscoverFragmentAdapter

use of me.yokeyword.sample.demo_flow.adapter.DiscoverFragmentAdapter in project Fragmentation by YoKeyword.

the class DiscoverFragment method initView.

private void initView(View view) {
    Toolbar mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
    TabLayout mTabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
    ViewPager mViewPager = (ViewPager) view.findViewById(R.id.viewPager);
    mToolbar.setTitle("发现");
    initToolbarNav(mToolbar);
    mTabLayout.addTab(mTabLayout.newTab().setText(R.string.recommend));
    mTabLayout.addTab(mTabLayout.newTab().setText(R.string.hot));
    mTabLayout.addTab(mTabLayout.newTab().setText(R.string.favorite));
    mViewPager.setAdapter(new DiscoverFragmentAdapter(getChildFragmentManager()));
    mTabLayout.setupWithViewPager(mViewPager);
}
Also used : TabLayout(android.support.design.widget.TabLayout) ViewPager(android.support.v4.view.ViewPager) DiscoverFragmentAdapter(me.yokeyword.sample.demo_flow.adapter.DiscoverFragmentAdapter) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

TabLayout (android.support.design.widget.TabLayout)1 ViewPager (android.support.v4.view.ViewPager)1 Toolbar (android.support.v7.widget.Toolbar)1 DiscoverFragmentAdapter (me.yokeyword.sample.demo_flow.adapter.DiscoverFragmentAdapter)1