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