Created
September 26, 2018 06:51
-
-
Save codeamt/0b5f232a7a908333c76909c9befc4c00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void inflateTabs(Sandwich sandwich) { | |
toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar); | |
setSupportActionBar(toolbar); | |
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); | |
tabLayout.addTab(tabLayout.newTab().setText("Background")); | |
tabLayout.addTab(tabLayout.newTab().setText("Ingredients")); | |
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); | |
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); | |
final PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount()); | |
viewPager.setAdapter(adapter); | |
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); | |
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment