【发布时间】:2011-03-11 10:58:53
【问题描述】:
如何在BitmapDrawable 构造函数中设置资源?在下面的示例中,我想将资源设置为 R.drawable.default_fb_pic,这是一个 ID,而不是资源。我怎样才能获得资源?
使用ImageView,我们可以设置资源及其 ID:
imageview.setImageResource(R.drawable.whatever);
我不太清楚为什么有时可以直接使用其 ID 设置资源,而有时则不能。
有人可以帮忙吗?
static class DownloadedDrawable extends BitmapDrawable {
public DownloadedDrawable(BitmapDownloaderTask bitmapDownloaderTask) {
super(R.drawable.default_fb_pic); //"The constructor BitmapDrawable(int)
//is undefined",
//which I understand because it takes a resource.
//But how do I get the resource and why is there no constructor
//directly with the id?
}
...
}
【问题讨论】:
标签: android resources drawable