当前位置:首页 > 技术心得 > 正文内容

android动态改变ActionBar中MenuItem的图标

xjtudll11年前 (2015-07-03)技术心得10090

先调用方法:invalidateOptionsMenu();

然后系统会自动回调方法:onPrepareOptionsMenu

在onPrepareOptionsMenu中改变MenuItem的图标即可。

例如:

MenuItem item = menu.findItem(R.id.share);

item.setIcon(R.drawable.share);

扫描二维码推送至手机访问。

版权声明:本文由鸟的天空发布,如需转载请注明出处。

本文链接:http://xjtudll.cn/Exp/361/

标签: Android
分享给朋友:

“android动态改变ActionBar中MenuItem的图标” 的相关文章

ios设备分辨率、屏幕尺寸、屏幕密度

iPhone Devices iPhone 5S Retina 4" Screen 326ppi 16:9 640 x 1136 px 123.8 x 58.6 x 7.6 mm 112...

SQL去掉小数点有效数字后的所有0

第一种方法 select cast(2.5000000000000   as  real) select cast(2   as  real) select cast(2.00000   as  r...

sqlserver数据库触发器调用外部exe

sqlserver数据库触发器调用外部exe

https://www.cnblogs.com/syp1Blog/p/9482088.html sqlserver数据库触发器调用外部exe,同事可以选择参入参数! sqlserver使用 master..xp_cmdshell 进行外部exe的执行。 使用master..xp_cmdshell 之...

黑群晖:certificate has expired or is not yet valid

https://blog.csdn.net/weixin_54655073/article/details/138663733 sudo -imv /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt.baksud...

用宏定义代替printf函数

问题 有时候我们想用宏定义来决定是编译debug版本的代码还是release的代码,dubug版本的代码会通过printf打印调试信息,release版本的代码则不会。我们总不能对每一条printf都这样写: #if _DEBUG_printf("hello world!");...

图像不能包含 alpha 通道或透明度

将app上传到应用市场时,都会要求提供app图标,但是上传时,有时候就会碰到: “图像不能包含 alpha 通道或透明度” 如何解决这个问题呢? 将图片另存为 jpeg格式。如果要求png格式,那么再将jpeg转成png, 使用工具:windows自带的画图。...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。