Search in sources :

Example 1 with SimpleFragment

use of com.zhy.sample.fragment.SimpleFragment in project AndroidAutoLayout by hongyangAndroid.

the class CategoryActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_category);
    mTabLayout = (TabLayout) findViewById(R.id.id_tablayout);
    mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
    mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int i) {
            return new SimpleFragment();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mTabTitles[position];
        }

        @Override
        public int getCount() {
            return mTabTitles.length;
        }
    });
    mTabLayout.setupWithViewPager(mViewPager);
}
Also used : SimpleFragment(com.zhy.sample.fragment.SimpleFragment) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) Fragment(android.support.v4.app.Fragment) SimpleFragment(com.zhy.sample.fragment.SimpleFragment)

Aggregations

Fragment (android.support.v4.app.Fragment)1 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)1 SimpleFragment (com.zhy.sample.fragment.SimpleFragment)1