出现在Android的动作条编程的方法修改标志 [英] Change logo that appears in Android ActionBar programatically

查看:137
本文介绍了出现在Android的动作条编程的方法修改标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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);

这篇关于出现在Android的动作条编程的方法修改标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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