From the course: Android Development Essential Training: 3 Navigation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

✓ Solution: Badge of honor

✓ Solution: Badge of honor - Android Tutorial

From the course: Android Development Essential Training: 3 Navigation

Start my 1-month free trial

✓ Solution: Badge of honor

(upbeat music) - [Instructor] Welcome back. Let's jump into my solution to the "Badge of Honor Challenge." For this challenge, I wanted you to update a skeleton application to display a badge on your bottom navigation view. When the user clicks to increase the quantity, we want to display the new count on the badge number, just like this. However, if they decrease the quantity all the way down to zero, we want to clear the count and hide the badge. Let's take a look at my solution to this challenge. Since I provided a skeleton for you, there was one function you needed to implement, update badge. This function is inside of the main activity class. It gets called whenever the total quantity changes. So the first step would be to get access to the badge for our shop menu item. We do that by the code you see here on line number 45. We use the get or create badge function. How this works, the first time the function is…

Contents