Android-ActionItemBadge
ActionItemBadge is a library which offers a simple and easy to use method to add a badge to your action item!
Include in your project
Using Maven
The ActionItemBadge Library is pushed to [Maven Central], so you just need to add the following dependency to your build.gradle
.
Additional dependency for the icon font
If you are going to use the icon font you will have to add additional dependency for the font.
You can find all available addons here: https://github.com/mikepenz/Android-Iconics#2-choose-your-desired-fonts
UPGRADE NOTES
< 3.0.0
- If you come from a version prior 3.0.0 you will have to rename some classes, and the default styles also found a new place. Just check out the updated sample app for all the changes.
Usage
menu.xml
Create your menu.xml as you would do normally and add the app:actionLayout param.
It is also a good idea to set showAsAction="always" (The badge can only be shown in the actionbar)
Activity
Override the onCreateOptionsMenu method
If you want to update the item itself you can do the required stuff in the onOptionsItemSelected method and
call invalidateOptionsMenu() afterwards.