Search in sources :

Example 1 with SimpleFragment

use of com.zhy.autolayout.test.widgets.fragments.SimpleFragment in project AndroidAutoLayout by hongyangAndroid.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("标题");
    setSupportActionBar(toolbar);
    mTabLayout = (TabLayout) findViewById(R.id.id_tablayout);
    mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
    mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

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

        @Override
        public int getCount() {
            return 2;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return "Page " + position;
        }
    });
    mTabLayout.setupWithViewPager(mViewPager);
}
Also used : SimpleFragment(com.zhy.autolayout.test.widgets.fragments.SimpleFragment) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) Fragment(android.support.v4.app.Fragment) SimpleFragment(com.zhy.autolayout.test.widgets.fragments.SimpleFragment) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Fragment (android.support.v4.app.Fragment)1 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)1 Toolbar (android.support.v7.widget.Toolbar)1 SimpleFragment (com.zhy.autolayout.test.widgets.fragments.SimpleFragment)1