title: Check Tab Position in ViewPager Adapter
body: <p>Strangely there is not a single method available to get exact position of selected tab in viewPager adapter,</p>
  
  <p>In <code>instantiateItem</code> you need to decide what layout to use for a given tab in viewPager , but <code>position</code> of <code>instantiateItem</code> is not actually the exact position , so how can i decide which tab is selected and decide what xml to inflate ?</p>
  
  <p>There are number of SO question answered for the same issue , and they doesn't make sense at all <a href="https://stackoverflow.com/a/8117710/5896744">Q1</a> .</p>
  
  <p>In this given <a href="https://stackoverflow.com/a/8258800/5896744">Question</a> , it doesn't make sense to get the selected tab position when layout is already inflated in my case.</p>
  
  <p>My Attempts:</p>
  
  <ul>
  <li><p>Get position by calling <code>getItemPosition()</code> in <code>instantiateItem</code> doesn't work , give -1 always.</p></li>
  <li><p>Get position of tab using actually <code>position</code> parameter in <code>instantiateItem</code> , doesn't work give strange random values.</p></li>
  </ul>
  
  <p>Any solutions/workarounds ?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Link for code of activity i'm using right now <a href="https://github.com/DevLight-Mobile-Agency/NavigationTabBar/blob/master/app/src/main/java/com/gigamole/sample/HorizontalCoordinatorNtbActivity.java" rel="nofollow noreferrer">HorizontalCoordinatorNtbActivity.java</a> , specifically check <strong>line 55</strong></p>