Android - incremental status bar notification icon

此生再无相见时 提交于 2019-12-20 12:37:12

问题


You know what I'm talking about: for example when you get multiple new emails the notification icon in the status bar is augmented with a little red circle that contains number of unread mails. Twitroid has the same icon. Any idea how it's done? I don't think (or so I hope) there are 10000 similar icons. Is this red circle generated and overlaid the notification icon? If so - any code snippets will be much appreciated.


回答1:


This one is nice and easy, just change Notification.number to whatever number you want to appear on your Notification, e.g.:

Notification notification = new Notification(icon, tickerText, when);
notification.number = 4;



回答2:


A good example of how to use the notification bar can be found in this tutorial:

http://www.firstdroid.com/2010/05/09/learn-by-example-using-notification-bar/

Hope it helps, Adrian.



来源:https://stackoverflow.com/questions/1929791/android-incremental-status-bar-notification-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!