Question: I am using the android design library TabLayout in that how can I get the current selected item tab position.

```
  ViewPager pager = (ViewPager) view.findViewById(R.id.pager);      
  MyPagerAdapter adapter = new MyPagerAdapter(getChildFragmentManager());
  pager.setAdapter(adapter);
  tabLayout.setupWithViewPager(pager);

```

Answer: 
As of version 22.2.1 of the Support library the [TabLayout](http://developer.android.com/reference/android/support/design/widget/TabLayout.html) has a method `getSelectedTabPosition`.

[Source 1](https://plus.google.com/+AndroidDevelopers/posts/XTtNCPviwpj) | [Source 2](https://developer.android.com/sdk/support_api_diff/22.2.1/changes.html#AndroidDev)
```
  mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            int position = tab.getPosition();
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
        }

```