2
反正是有通过类来传递一个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
这样的课程。
这是否回答你的问题? http://stackoverflow.com/questions/10070974/how-to-pass-drawable-using-parcelable – MidasLefko
你的'loadImage'方法需要'int'作为第二个参数,而不是'Drawable' – pskink