Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add badge later #31

Closed
EpsilonOrionis opened this issue May 25, 2016 · 4 comments
Closed

Add badge later #31

EpsilonOrionis opened this issue May 25, 2016 · 4 comments

Comments

@EpsilonOrionis
Copy link

Is it possible to add a badge for a specific tab, when the BottomBar is already created?

@Ashok-Varma
Copy link
Owner

you can Add the badge before creating the BottomBar. and make the badge hide. whenever requires you can call show.

Here is the sample code snippet.

  1. First during Initialisation :
//-------------------------------------------------------------
BadgeItem numberBadgeItem = new BadgeItem()
                .setBorderWidth(4)
                .setBackgroundColorResource(R.color.blue)
                .setText("hai");
//-------------------------------------------------------------
bottomNavigationBar
                    .addItem(new BottomNavigationItem(R.drawable.ic_location_on_white_24dp, "Location").setActiveColorResource(R.color.orange).setBadgeItem(numberBadgeItem))
                    .addItem(new BottomNavigationItem(R.drawable.ic_find_replace_white_24dp, "Find").setActiveColorResource(R.color.teal))
                    .addItem(new BottomNavigationItem(R.drawable.ic_favorite_white_24dp, "Favorites").setActiveColorResource(R.color.blue))
                    .setFirstSelectedPosition(1)
                    .initialise();
//-------------------------------------------------------------
numberBadgeItem.hide();
  1. When ever you need the badge :
numberBadgeItem.show().setText("1") 

@Ashok-Varma
Copy link
Owner

@EpsilonOrionis if it works you can close this issue

@Ashok-Varma
Copy link
Owner

Ashok-Varma commented May 31, 2016

in 1.2.2 you can call hide on badge before attaching it to the bottomNavigationBar.

Here is the sample code snippet.

  1. First during Initialisation :
//-------------------------------------------------------------
BadgeItem numberBadgeItem = new BadgeItem()
                .setBorderWidth(4)
                .setBackgroundColorResource(R.color.blue)
                .setText("hai")
                .hide();
//-------------------------------------------------------------
bottomNavigationBar
                    .addItem(new BottomNavigationItem(R.drawable.ic_location_on_white_24dp, "Location").setActiveColorResource(R.color.orange).setBadgeItem(numberBadgeItem))
                    .addItem(new BottomNavigationItem(R.drawable.ic_find_replace_white_24dp, "Find").setActiveColorResource(R.color.teal))
                    .addItem(new BottomNavigationItem(R.drawable.ic_favorite_white_24dp, "Favorites").setActiveColorResource(R.color.blue))
                    .setFirstSelectedPosition(1)
                    .initialise();
  1. When ever you need the badge just call show:
numberBadgeItem.show().setText("1") 

@EpsilonOrionis
Copy link
Author

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants