在构造函数中设置BitmapDrawable资源

jul*_*jul 1 resources android drawable

如何在BitmapDrawable构造函数中设置资源?在下面的示例中,我想将资源设置R.drawable.default_fb_pic为ID,而不是资源.我怎样才能获得资源?随着ImageView我们可以设置其ID的资源:

imageview.setImageResource(R.drawable.whatever);  
Run Code Online (Sandbox Code Playgroud)

我不清楚为什么有时可以使用其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?
    }

    ...
}
Run Code Online (Sandbox Code Playgroud)