{"id":13463493,"url":"https://github.com/mikepenz/Android-ActionItemBadge","last_synced_at":"2025-03-25T06:32:11.798Z","repository":{"id":18955120,"uuid":"22175394","full_name":"mikepenz/Android-ActionItemBadge","owner":"mikepenz","description":"This library offers a simple method to add a small badge icon to your ActionBar-MenuItem","archived":false,"fork":false,"pushed_at":"2020-06-14T15:11:19.000Z","size":1060,"stargazers_count":1274,"open_issues_count":0,"forks_count":220,"subscribers_count":48,"default_branch":"develop","last_synced_at":"2024-10-16T09:06:49.007Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://mikepenz.github.io/Android-ActionItemBadge","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikepenz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["mikepenz"]}},"created_at":"2014-07-23T20:23:45.000Z","updated_at":"2024-06-10T16:02:43.000Z","dependencies_parsed_at":"2022-07-25T06:47:05.909Z","dependency_job_id":null,"html_url":"https://github.com/mikepenz/Android-ActionItemBadge","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikepenz%2FAndroid-ActionItemBadge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikepenz%2FAndroid-ActionItemBadge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikepenz%2FAndroid-ActionItemBadge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikepenz%2FAndroid-ActionItemBadge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikepenz","download_url":"https://codeload.github.com/mikepenz/Android-ActionItemBadge/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222045615,"owners_count":16921984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T13:00:54.357Z","updated_at":"2024-10-29T12:31:27.048Z","avatar_url":"https://github.com/mikepenz.png","language":"Java","funding_links":["https://github.com/sponsors/mikepenz","http://paypal.me/mikepenz"],"categories":["徽章(Badge)","Java","Libs","Uncategorized"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget","Uncategorized"],"readme":"# Android-ActionItemBadge [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.mikepenz/actionitembadge/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/com.mikepenz/actionitembadge) [![Android Arsenal](http://img.shields.io/badge/Android%20Arsenal-Android--ActionItemBadge-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/755)\n\n[![Join the chat at https://gitter.im/mikepenz/Android-ActionItemBadge](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mikepenz/Android-ActionItemBadge?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nActionItemBadge is a library which offers a simple and easy to use method to add a badge to your action item!\n\n## Screenshots\n![Image](https://raw.githubusercontent.com/mikepenz/Android-ActionItemBadge/develop/DEV/screenshot/screenshot1_small.png)\n![Image](https://raw.githubusercontent.com/mikepenz/Android-ActionItemBadge/develop/DEV/screenshot/screenshot2_small.png)\n\n## Include in your project\n### Using Maven\nThe ActionItemBadge Library is pushed to [Maven Central], so you just need to add the following dependency to your `build.gradle`.\n\n```javascript\ndependencies {\n\timplementation 'com.mikepenz:actionitembadge:4.0.0'\n\n\t//SUB-DEPENDENCIES\n\t//Android-Iconics - used to provide an easy API for icons \n\timplementation 'com.mikepenz:iconics-core:{latestVersion}@aar'\n}\n```\n\n### Additional dependency for the icon font\nIf you are going to use the icon font you will have to add additional dependency for the font. \nYou can find all available addons here: https://github.com/mikepenz/Android-Iconics#2-choose-your-desired-fonts\n\n## UPGRADE NOTES\n#### \u003c 4.0.0\n- If you come from a version prior 4.0.0 you will have to upgrade to AndroidX and Iconics v4\n\n#### \u003c 3.0.0\n- 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.\n\n## Usage\n### menu.xml\nCreate your menu.xml as you would do normally and add the app:actionLayout param.\nIt is also a good idea to set showAsAction=\"always\" (The badge can only be shown in the actionbar)\n```xml\n\u003cmenu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      xmlns:tools=\"http://schemas.android.com/tools\"\n      xmlns:app=\"http://schemas.android.com/apk/res-auto\"\u003e\n    \u003citem\n        android:id=\"@+id/item_samplebadge\"\n        app:actionLayout=\"@layout/menu_action_item_badge\"\n        app:showAsAction=\"always\"\n        android:title=\"@string/sample_1\"/\u003e\n\u003c/menu\u003e\n```\n### Activity\nOverride the onCreateOptionsMenu method\n```java\n @Override\n    public boolean onCreateOptionsMenu(Menu menu) {\n        // Inflate the menu; this adds items to the action bar if it is present.\n        getMenuInflater().inflate(R.menu.main, menu);\n\n\t    //you can add some logic (hide it if the count == 0)\n        if (badgeCount \u003e 0) {\n            ActionItemBadge.update(this, menu.findItem(R.id.item_samplebadge), FontAwesome.Icon.faw_android, ActionItemBadge.BadgeStyles.DARK_GREY, badgeCount);\n        } else {\n            ActionItemBadge.hide(menu.findItem(R.id.item_samplebadge));\n        }\n\n\t    //If you want to add your ActionItem programmatically you can do this too. You do the following:\n        new ActionItemBadgeAdder().act(this).menu(menu).title(R.string.sample_2).itemDetails(0, SAMPLE2_ID, 1).showAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS).add(bigStyle, 1);\n        return super.onCreateOptionsMenu(menu);\n    }\n```\n\nIf you want to update the item itself you can do the required stuff in the onOptionsItemSelected method and\ncall invalidateOptionsMenu() afterwards.\n```java\n    @Override\n    public boolean onOptionsItemSelected(MenuItem item) {\n        int id = item.getItemId();\n        if (id == R.id.item_samplebadge) {\n            Toast.makeText(this, R.string.sample_3, Toast.LENGTH_SHORT).show();\n            badgeCount--;\n            ActionItemBadge.update(item, badgeCount);\n            return true;\n        } else if (id == SAMPLE2_ID) {\n            Toast.makeText(this, R.string.sample_4, Toast.LENGTH_SHORT).show();\n        }\n        return super.onOptionsItemSelected(item);\n    }\n```\n\n# Dependencies\n* Android-Iconics - https://github.com/mikepenz/Android-Iconics\n\n\n# Developed By\n\n* Mike Penz \n * [mikepenz.com](http://mikepenz.com) - \u003cmikepenz@gmail.com\u003e\n * [paypal.me/mikepenz](http://paypal.me/mikepenz)\n\n# License\n\n    Copyright 2019 Mike Penz\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikepenz%2FAndroid-ActionItemBadge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikepenz%2FAndroid-ActionItemBadge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikepenz%2FAndroid-ActionItemBadge/lists"}