出现在Android的动作条编程的方法修改标志出现在、标志、动作、方法

由网友(不吃鱼的猫)分享简介:有没有办法改变这种状况,列出它出现在的动作条的活动里面而不是标志该清单? Is there a way to change the logo that appears in the ActionBar inside an Activity instead of listing it in the Manifest?...

有没有办法改变这种状况,列出它出现在的动作条活动里面而不是标志该清单?

Is there a way to change the logo that appears in the ActionBar inside an Activity instead of listing it in the Manifest?

我想问的原因是我有手机,我建立在顶部相似类型的酒吧,在相似的左上角的启动器图标的应用程序的动作条使用的ImageView

The reason I ask is I have an app for phones where I build a similar type of bar across the top with the launcher icon in the left corner similar to the ActionBar using an ImageView.

我也允许用户该图像更改为他们的电话或互联网上。我目前正在为平板电脑应用程序的工作,并希望只使用了动作条来代替,但无法弄清楚如何改变基于用户的图像。有一个在动作条类没有办法,我无法找到一个方法来修改从资源的图标或标志。

I also allow the user to change that image to one on their phone or on the internet. I am currently making the app work for tablets and would like to just use the ActionBar instead but can't figure out how to change the image based on the user. There is no method in the ActionBar class and I could not find a way to modify the icon or logo from the resources.

任何人都知道这是可能或可能提出一些我能试试吗?

Anyone know if this is possible or could suggest something I could try?

推荐答案

此前推出的API 14的的setIcon setLogo 方法杰克提到,你似乎能够通过抓住 android.R.id.home ,并创下新的绘制来改变动作条标志

Prior to the introduction in API 14 of the setIcon and setLogo methods that Jake mentions, you appear to be able to change the ActionBar logo by grabbing the view of android.R.id.home and setting a new drawable.

ImageView logo = (ImageView) findViewById(android.R.id.home);
logo.setImageDrawable(drawable);