如何实现对Android的菜单项动态值 [英] How to implement dynamic values on menu item in Android

查看:213
本文介绍了如何实现对Android的菜单项动态值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在操作栏的菜单项。沿着与上述菜单项目图像,我需要显示与它相关的一些数目这将经常改变。我不使用操作栏福尔摩斯。我不希望使用的。除了这一切只是工作正常。在显示图像时,白色图标的颜色图标是我的。我需要动态生成具有红色背景的数目。我怎样才能做到这一点在Android的?

I have a menu item in the action bar. Along with the menu item image, I need to show some number associated with it which will change often. I am not using Action bar sherlock. I don't want to use that. Other than this everything else just works fine. In the shown image, the white icon color icon is mine. I need to generate the number with the red color background dynamically. How can I do that in Android?

下面的示例图像:

更新:

我在menu.xml文件这个菜单项。这应该工作就像一个通知菜单项,显示通知张数。我设置了菜单图标一样,

I have this menu item in my menu.xml. This should work like a notification menu item which shows the number of notification count. I set the menu icon like,

 menuItem.setIcon(image);

现在,在菜单项的顶部,我需要的地方有通知的总数一个文本视图。

Now, on top of the menu item I need to place one text view which has the total count of notifications.

是有可能实现这一功能viewbadger? Github上网址

is it possible to implement this functionality with viewbadger? Github url

推荐答案

我发现了一个而ActionView添加到菜单项和检索的设定值在code中的视图。

I discovered how to add an actionView to a menu item and retrieve as set values to the view in code.

在这里看到: http://stackoverflow.com/a/16648170/857681

这篇关于如何实现对Android的菜单项动态值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆