roughike / BottomBar

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

open third tab onstart #879

Open rajesh-codes opened 6 years ago

rajesh-codes commented 6 years ago

Assume I have five items in my menu. So I just want to open third tab on starting of the app. Currently it actually starts the first tab. So how to get third tab to be opened onstart?

MadAxon commented 6 years ago

just call bottomBar.selectTabAtPosition(2); before you set bottomBar.setOnTabSelectListener

rajesh-codes commented 6 years ago

Not working...if call that before .setOnTabSelectListener , it is saying app is stopped unfortunately.

MadAxon commented 6 years ago

Hmm... But it's working for me. I did this way: `

    bottomBar = findViewById(R.id.bottomBar);
    bottomBar.selectTabAtPosition(1);
    bottomBar.setOnTabSelectListener(new OnTabSelectListener() {
        @Override
        public void onTabSelected(@IdRes int tabId) {
            switch (tabId) {
                case R.id.tab_home:
                    <some code>
                case R.id.tab_profile:
                      <some code>
            }
        }
    });`

Can you provide a stack trace? Maybe your app simply catches nullpointerexception?