如何将Drawable传递给一个类?

时间:2015-08-16 04:47:41

标签: java android android-drawable

无论如何都要将Drawable传递给像这样的类:

public loadImage(Context context, int drawable, int x, int y, int width, int height) {
    this.drawable = context.getResources().getDrawable(drawable);
    this.x = x;
    this.y = y;
    this.width = width;
    this.height = height;
}

尝试将Drawable传递给班级:

candyImg = new loadImage(getContext(), getResources().getDrawable(R.drawable.candy), 0, 0, 50, 50);

它说getResources().getDrawable(drawable);已被弃用。那么我怎样才能将Drawable传递给像这样的类。

0 个答案:

没有答案
相关问题