动作条获取当前的图标,findviewbyid [英] ActionBar get current icon, findviewbyid

查看:139
本文介绍了动作条获取当前的图标,findviewbyid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何设置的动作条的图标,但我怎么确定哪些图标,目前有?我没有看到像调用getIcon 的访问,我认为这是可以通过ID查找图标视图,因为我已经在动作条做到了这一点与搜索窗口小部件,但我不知道叫什么ID。

I know how to set the icon of the actionbar, but how do I determine what icon is currently there? I don't see an accessor like getIcon , I think it is possible to find the icon view by id, since I've done this with the search widget in the actionbar, but I wouldn't know what id to call.

推荐答案

ActionBarView.HomeView 来源$ C ​​$ C,你应该能够得到的ImageView 图标由 android.R.id.home

According to the source code of ActionBarView.HomeView you should be able to get ImageView of icon by android.R.id.home.

所以,code可能看起来像:

So code may look like:

ImageView imageView = (ImageView) findViewById(android.R.id.home);
Drawable dr = imageView.getDrawable();

不知道这是否会与支持库

Not sure if this will work with support libraries

这篇关于动作条获取当前的图标,findviewbyid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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