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: 
```
  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) {
        }

```
**[Updated 29-07-2016]**

**Refer the accepted answer because below answer is deprecated. If you are using older version then refer it.**

You can do it easily ...

```
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                @Override
                public void onTabSelected(TabLayout.Tab tab) {
                    pos = tab.getPosition();
                }

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

                }

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

                }
            });

```