由网友(你的账号已冻结)分享简介:我有一个形象 RES /绘制/ test.png (R.drawable.test)。我想通过这个形象,它接受绘制对象函数。(例如mButton.setCompoundDrawables())I have a image res/drawable/test.png (R.drawable.test).I wan...
我有一个形象 RES /绘制/ test.png
(R.drawable.test)。
我想通过这个形象,它接受绘制对象
函数。
(例如mButton.setCompoundDrawables())
I have a image res/drawable/test.png
(R.drawable.test).
I want to pass this image to a function which accepts Drawable
.
(e.g. mButton.setCompoundDrawables())
那么如何将图像资源转换为绘制对象
?
So how to convert a image resource to an Drawable
?
推荐答案
您的活动应具备的方法getResources。做:
Your Activity should have the method getResources. Do:
Drawable myIcon = getResources().getDrawable( R.drawable.icon );
相关推荐
最新文章