6

I have created a toolbar with a tabpane(Background, TextStyle, font). But I followed serval tutorials on the web and all have it with viewPager/slider which i dont want. So how do I create it without implementing viewPager?

So far I know its something to do with this:

@Override
public void onTabSelected(TabLayout.Tab tab) {

}

2 Answers2

17

Example code:

private void onCreateTabLayout() {
    mTabLayout.addTab(mTabLayout.newTab().setIcon(R.drawable.ic_directions_car_24dp));
    mTabLayout.addTab(mTabLayout.newTab().setIcon(R.drawable.ic_directions_walk_24dp));
    mTabLayout.addTab(mTabLayout.newTab().setIcon(R.drawable.ic_directions_bike_24dp));
    mTabLayout.setOnTabSelectedListener(this);
}
Tobrun
  • 18,291
  • 10
  • 66
  • 81
  • I m getting java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/internal/widget/TintManager; this error, please suggest – jyomin Mar 01 '16 at 06:54
  • 1
    This is related to not having your supportlibraries up to date – Tobrun Mar 01 '16 at 14:11
0

I solved my problem my using this code: https://stackoverflow.com/a/9650884/4646951

it did exactly what I wanted, which was deactivate the touch-swiping between my fragments and only allow "clicks" on the tabs

Community
  • 1
  • 1