Search in sources :

Example 1 with MiddleFragment

use of com.ximsfei.skindemo.tab.MiddleFragment in project Android-skin-support by ximsfei.

the class MainActivity method configFragments.

private void configFragments() {
    List<Fragment> list = new ArrayList<>();
    list.add(new FirstFragment());
    list.add(new MiddleFragment());
    list.add(new LastFragment());
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    viewPager.setAdapter(new TabFragmentPagerAdapter(getSupportFragmentManager(), list));
    List<String> listTitle = new ArrayList<>();
    listTitle.add("系统组件");
    listTitle.add("自定义View");
    listTitle.add("第三方库控件");
    mTabFragmentPagerAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager(), list, listTitle);
    viewPager.setAdapter(mTabFragmentPagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : MiddleFragment(com.ximsfei.skindemo.tab.MiddleFragment) LastFragment(com.ximsfei.skindemo.tab.LastFragment) FirstFragment(com.ximsfei.skindemo.tab.FirstFragment) TabLayout(android.support.design.widget.TabLayout) ArrayList(java.util.ArrayList) TabFragmentPagerAdapter(com.ximsfei.skindemo.tab.TabFragmentPagerAdapter) LastFragment(com.ximsfei.skindemo.tab.LastFragment) FirstFragment(com.ximsfei.skindemo.tab.FirstFragment) Fragment(android.support.v4.app.Fragment) MiddleFragment(com.ximsfei.skindemo.tab.MiddleFragment) ViewPager(android.support.v4.view.ViewPager)

Aggregations

TabLayout (android.support.design.widget.TabLayout)1 Fragment (android.support.v4.app.Fragment)1 ViewPager (android.support.v4.view.ViewPager)1 FirstFragment (com.ximsfei.skindemo.tab.FirstFragment)1 LastFragment (com.ximsfei.skindemo.tab.LastFragment)1 MiddleFragment (com.ximsfei.skindemo.tab.MiddleFragment)1 TabFragmentPagerAdapter (com.ximsfei.skindemo.tab.TabFragmentPagerAdapter)1 ArrayList (java.util.ArrayList)1