TabLayout tab selection

前端 未结 25 1501
情深已故
情深已故 2020-11-29 17:15

How should I select a tab in TabLayout programmatically?

 TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
 tabLayout.setupWithViewPager(viewPager         


        
25条回答
  •  臣服心动
    2020-11-29 17:47

    You can set TabLayout position using following functions

    public void setTab(){
     tabLayout.setScrollPosition(YOUR_SCROLL_INDEX,0,true);
     tabLayout.setSelected(true);
    }
    

提交回复
热议问题