I found out something interesting the getItemViewPosition always return null after added all the items, but it won't return null if I put under setOnTabSelectedListener.
Here is the code snippet
homepageTab.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW);
homepageTab.setAccentColor(getResources().getColor(R.color.colorPrimary));
homepageTab.setForceTint(true);
AHBottomNavigationItem item1 = new AHBottomNavigationItem("Questions",
R.drawable.survey_tab_icon);
AHBottomNavigationItem item2 = new AHBottomNavigationItem("Nearby",R.drawable.peoplenearby );
AHBottomNavigationItem item3 = new AHBottomNavigationItem("Chat",
R.drawable.message_selector);
AHBottomNavigationItem item4 = new AHBottomNavigationItem("Me", R.drawable.me_selector);
ArrayList< AHBottomNavigationItem> itemArrayList = new ArrayList<>();
itemArrayList.add(item1);
itemArrayList.add(item2);
itemArrayList.add(item3);
itemArrayList.add(item4);
// Add items
homepageTab.addItems(itemArrayList);
homepageTab.setCurrentItem(0);
// for smooth swipe
viewPager.setOffscreenPageLimit(3);
Log.d("HomePage123","OutSide tabSelected " + homepageTab.getViewAtPosition(0) );
// Set listeners
homepageTab.setOnTabSelectedListener(new AHBottomNavigation.OnTabSelectedListener() {
@Override
public boolean onTabSelected(int position, boolean wasSelected) {
viewPager.setCurrentItem(position,false);
homepageTab.getViewAtPosition(0);
Log.d("HomePage123","Under tabSelected " + homepageTab.getViewAtPosition(0) );
return true;
}
});
I found out something interesting the getItemViewPosition always return null after added all the items, but it won't return null if I put under setOnTabSelectedListener. Here is the code snippet homepageTab.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW); homepageTab.setAccentColor(getResources().getColor(R.color.colorPrimary)); homepageTab.setForceTint(true);
Here is the log output :![image](https://user-images.githubusercontent.com/22083254/43341973-24526490-91af-11e8-87ad-7aed9601433b.png)