Adding Sliding Tabs using Support Library v7:21 with Toolbar in Android Developer Tools for existing project

后端 未结 4 1055
青春惊慌失措
青春惊慌失措 2020-12-30 08:55

I have already read the information in this link: Use Tab with new ToolBar (AppCompat v7-21) and did a lot of research on the same.

But the problem is the SlidingTab

4条回答
  •  佛祖请我去吃肉
    2020-12-30 09:02

    Just add ViewPager and SlidingTabLayout to your xml:

        
    
        
    

    In your Code create an Adapter for your ViewPager (as example FragmentPagerAdapter) and bind them to your ViewPager, after bind the SlidingTabLayout to your ViewPager:

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    
    final SlidingTabLayout tabLayout = (SlidingTabLayout)findViewById(R.id.sliding_tabs);
    tabLayout.setViewPager(mViewPager);
    

提交回复
热议问题