roughike / BottomBar

(Deprecated) A custom view component that mimics the new Material Design Bottom Navigation pattern.
Apache License 2.0
8.42k stars 1.51k forks source link

CHANGE CHECKED TAB ITEM MANUALLY #736

Open WK-SHUBHAM-AGARWAL opened 7 years ago

WK-SHUBHAM-AGARWAL commented 7 years ago

First of all thanks for the great library.

I have a query as I checked in both BottomBar class and BottomBarTab class but could not find the public setter for my query.

How can we change the check of tab item manually e.g. on back stack change or on fragment pop from the back stack?

I believe public void selectTabAtPosition(int position) should not work here as it will call tab selected listener or private void updateSelectedTab(int newPosition) method.

I just want to know how we can achieve it this: // Android Default bottom navigation bottomNavigation.getMenu().findItem(R.id.navigation_home).setChecked(true);

that is changing the selection without triggering the listener (without using flags I mean is there any public accessor available)

Thanks for maintaining such a great library and your time

WK-SHUBHAM-AGARWAL commented 7 years ago

@roughike please look into the problem.

yombunker commented 7 years ago

@WK-SHUBHAM-AGARWAL i don't think it currently has anything close to that, the closest thing would be for you to either remove the listener and added back after, or having some sort of flag in your listener to know that it needs to ignore the next switch of tabs.

WK-SHUBHAM-AGARWAL commented 7 years ago

@yombunker @roughike The problem was related to a scenario where I am hiding the bottom navigation or opening activity. In that case, whenever a user is done with the activity it shows the fragment from the current backstack. But the bottom bar is marked to the previous one correspond to the activity that has been closed. However, if I am using all the fragments for the bottom bar. It is working flawlessly.