![]() ![]() By using this method we add the tab which we created using newTab() method in the TabLayout. addTab(Tab tab, int position): This method is used to add a tab in the TabLayout and set the state for the tab. TabLayout.addTab(firstTab,true) // add the tab in the TabLayout and makes it selectableĤ. TabLayout tabLayout = (TabLayout) findViewById(R.id.simpleTabLayout) // get the reference of TabLayout ![]() In this method we also set the state of the tab whether it is selected or not.īelow we firstly create a new tab and then add it in the TabLayout and set the true value for setSelected parameter that makes it selectable. addTab(Tab tab, boolean setSelected):This method is used to add a tab in the TabLayout and set the state for the tab. TabLayout.addTab(firstTab) // add the tab to the TabLayoutģ. TabLayout.Tab firstTab = tabLayout.newTab() // Create a new Tab names "First Tab" The tab will be added at the end of the list and If it is the first tab to be added then it will become the selected tab.īelow we firstly create a new tab and then add it in the TabLayout. addTab(Tab tab): This method is used to add a tab in the TabLayout. TabLayout.Tab firstTab = tabLayout.newTab() // Create a new Tab namesįtText("First Tab") // set the Text for the first TabįtIcon(R.drawable.ic_launcher) // set an icon for the first tabĢ. ![]() Let’s we discuss some important methods of TabLayout that may be called in order to manage the TabLayout.ġ. newTab(): This method is used to create and return a new TabLayout.Tab.īelow we create a new tab and set the text and icon for the tab.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |