更改操作栏图标 [英] Changing the Action bar icon

查看:148
本文介绍了更改操作栏图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在实施的主题支持我的应用程序和它的一部分是改变操作栏中的应用程序图标。我想用一个黑暗的图标时,全息光被选中。一切都在该方法中,除了其中操作栏应用程序图标设置的一部分进行。在code,即时通讯试图使用方法是:

  getActionBar();
ActionBar.setIcon(R.drawable.my_icon);
 

这里有没有这样的参考avavible是,我发现了错误。应如何正确做?

顺便说一句我的minSdkVersion是14所以没有行动起来吧福尔摩斯的东西。

解决方案

  getActionBar();
 

你扔的动作栏离开那里。 getActionBar()返回动作条的一个实例,然后您再需要调用的setIcon() 上。像这样:

 动作条动作条= getActionBar();
actionBar.setIcon(R.drawable.my_icon);
 

I'm currently implementing theme support for my application and a part of it is changing the action bar app icon. I want to use a dark icon when Holo Light is selected. Everything is done in the method except for the part where the action bar app icon is set. The code that im trying to use is:

getActionBar();
ActionBar.setIcon(R.drawable.my_icon);

"There is no such reference avavible here" is the error that i'm getting. How should this be done correctly?

BTW my minSdkVersion is 14 so no action bar sherlock stuff.

解决方案

getActionBar();

You're throwing the action bar away right there. getActionBar() returns an instance of ActionBar, which you then need to call setIcon() on. Like so:

ActionBar actionBar = getActionBar();
actionBar.setIcon(R.drawable.my_icon);

这篇关于更改操作栏图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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