Search in sources :

Example 1 with FragmentPagerItemAdapter

use of com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter in project SmartTabLayout by ogaclejapan.

the class DemoLikeMediumActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_like_a_medium);
    Demo demo = getDemo();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(demo.titleResId);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ViewGroup tab = (ViewGroup) findViewById(R.id.tab);
    tab.addView(LayoutInflater.from(this).inflate(demo.layoutResId, tab, false));
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
    demo.setup(viewPagerTab);
    FragmentPagerItems pages = new FragmentPagerItems(this);
    for (int titleResId : demo.tabs()) {
        pages.add(FragmentPagerItem.of(getString(titleResId), DemoFragment.class));
    }
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);
    viewPager.setAdapter(adapter);
    viewPagerTab.setViewPager(viewPager);
}
Also used : FragmentPagerItems(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems) ViewGroup(android.view.ViewGroup) ViewPager(android.support.v4.view.ViewPager) FragmentPagerItemAdapter(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter) Toolbar(android.support.v7.widget.Toolbar) SmartTabLayout(com.ogaclejapan.smarttablayout.SmartTabLayout)

Example 2 with FragmentPagerItemAdapter

use of com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter in project SmartTabLayout by ogaclejapan.

the class DemoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    Demo demo = getDemo();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(demo.titleResId);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ViewGroup tab = (ViewGroup) findViewById(R.id.tab);
    tab.addView(LayoutInflater.from(this).inflate(demo.layoutResId, tab, false));
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
    demo.setup(viewPagerTab);
    FragmentPagerItems pages = new FragmentPagerItems(this);
    for (int titleResId : demo.tabs()) {
        pages.add(FragmentPagerItem.of(getString(titleResId), DemoFragment.class));
    }
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);
    viewPager.setAdapter(adapter);
    viewPagerTab.setViewPager(viewPager);
}
Also used : FragmentPagerItems(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems) ViewGroup(android.view.ViewGroup) ViewPager(android.support.v4.view.ViewPager) FragmentPagerItemAdapter(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter) Toolbar(android.support.v7.widget.Toolbar) SmartTabLayout(com.ogaclejapan.smarttablayout.SmartTabLayout)

Example 3 with FragmentPagerItemAdapter

use of com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter in project SmartTabLayout by ogaclejapan.

the class DemoRtlActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rtl);
    Demo demo = getDemo();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(demo.titleResId);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ViewGroup tab = (ViewGroup) findViewById(R.id.tab);
    tab.addView(LayoutInflater.from(this).inflate(demo.layoutResId, tab, false));
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    final SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
    demo.setup(viewPagerTab);
    FragmentPagerItems pages = new FragmentPagerItems(this);
    for (int titleResId : demo.tabs()) {
        pages.add(FragmentPagerItem.of(getString(titleResId), DemoFragment.class));
    }
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);
    viewPager.setAdapter(adapter);
    viewPagerTab.setViewPager(viewPager);
}
Also used : FragmentPagerItems(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems) ViewGroup(android.view.ViewGroup) ViewPager(android.support.v4.view.ViewPager) FragmentPagerItemAdapter(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter) Toolbar(android.support.v7.widget.Toolbar) SmartTabLayout(com.ogaclejapan.smarttablayout.SmartTabLayout)

Example 4 with FragmentPagerItemAdapter

use of com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter in project SmartTabLayout by ogaclejapan.

the class DemoTabWithNotificationMarkActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo_tab_with_notification_mark);
    final Demo demo = getDemo();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(demo.titleResId);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ViewGroup tab = (ViewGroup) findViewById(R.id.tab);
    tab.addView(LayoutInflater.from(this).inflate(demo.layoutResId, tab, false));
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    final SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
    viewPagerTab.setCustomTabView(this);
    FragmentPagerItems pages = new FragmentPagerItems(this);
    for (int titleResId : demo.tabs()) {
        pages.add(FragmentPagerItem.of(getString(titleResId), DemoFragment.class));
    }
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);
    viewPager.setAdapter(adapter);
    viewPagerTab.setViewPager(viewPager);
    viewPagerTab.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            View tab = viewPagerTab.getTabAt(position);
            View mark = tab.findViewById(R.id.custom_tab_notification_mark);
            mark.setVisibility(View.GONE);
        }
    });
    findViewById(R.id.test).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int position = Math.abs(random.nextInt()) % demo.tabs().length;
            View tab = viewPagerTab.getTabAt(position);
            View mark = tab.findViewById(R.id.custom_tab_notification_mark);
            mark.setVisibility(View.VISIBLE);
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) ViewPager(android.support.v4.view.ViewPager) ImageView(android.widget.ImageView) View(android.view.View) FragmentPagerItemAdapter(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter) FragmentPagerItems(com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems) Toolbar(android.support.v7.widget.Toolbar) SmartTabLayout(com.ogaclejapan.smarttablayout.SmartTabLayout)

Aggregations

ViewPager (android.support.v4.view.ViewPager)4 Toolbar (android.support.v7.widget.Toolbar)4 ViewGroup (android.view.ViewGroup)4 SmartTabLayout (com.ogaclejapan.smarttablayout.SmartTabLayout)4 FragmentPagerItemAdapter (com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter)4 FragmentPagerItems (com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems)4 View (android.view.View)1 ImageView (android.widget.ImageView)1