aurelhubert / ahbottomnavigation

A library to reproduce the behavior of the Bottom Navigation guidelines from Material Design.
3.84k stars 682 forks source link

setCurrentItem doesn't work #290

Closed aalap03 closed 6 years ago

aalap03 commented 6 years ago

Current Behaviour: I have 5 items in bottom navigation view, by default 1st item is coloured (Active or enable) when user comes here first.

Goal: In one scenario user can come to the app from notification and lands on 4th fragment. I want to make 4th fragment (3rd position in bottom view) coloured.

Issue: I tried using setCurrentItem(3) but still shows first item coloured.
Also tried bottomNavigation.enableItemAtPosition(3); but same result.

How to make this work ?

Ayesha-Fazal commented 6 years ago

i have the same issue here

aalap03 commented 6 years ago

Has anyone found its solution.. ??

aalap03 commented 6 years ago

Since this is very useful library and I really enjoy working with it, I am still trying to solve it and reading method descriptions and tried these combinations but still no impact. Image is there just to show what I need and what is happening.

        bottomNavigation.enableItemAtPosition(SECURITY);
        // true gives me bigger icon (as selected) but not the color which I want, colour is still on first item.
        bottomNavigation.setCurrentItem(SECURITY, true);

        bottomNavigation.setAccentColor(ContextCompat.getColor(this, R.color.colorPrimary));
        bottomNavigation.setInactiveColor(ContextCompat.getColor(this, R.color.black));

        bottomNavigation.refresh();
        bottomNavigation.restoreBottomNavigation();

screen shot 2017-11-01 at 17 04 41

aurelhubert commented 6 years ago

Be sure to call setCurrentItem() at the right moment. In the demo project, if you add bottomNavigation.setCurrentItem(2); at the end of initUI(), everything works fine.