I have implemented this example.
but not able to click on 2nd tab.
my xml file looks like
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header"
android:orientation="horizontal">
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:layout_below="@+id/header"
android:background="@color/colorPrimary"
app:tabSelectedTextColor="#ffffff" />
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/padding"
android:layout_height="wrap_content"
android:layout_below="@id/tab_layout" />
</LinearLayout>
and Main activity
pager= (ViewPager) findViewById(R.id.view_pager);
tabLayout= (TabLayout) findViewById(R.id.tab_layout);
FragmentManager manager=getSupportFragmentManager();
BuyCurrencyPagerAdapter adapter=new BuyCurrencyPagerAdapter(manager);
//set Adapter to view pager
pager.setAdapter(adapter);
tabLayout.setupWithViewPager(pager);
pager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setTabsFromPagerAdapter(adapter);
please give any suggestions.