【发布时间】:2013-05-29 20:50:32
【问题描述】:
我有一个 jpeg。我将它拖到 res 文件夹下名为 drawable-hdpi 的自动生成文件夹中。 所有教程都只使用“R.drawable.myimage”,但我收到错误“无法解析为变量” 以下是我的代码:
import android.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
public class MyCanvas extends View{
Bitmap bmp;
public MyCanvas(Context context) {
super(context);
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inJustDecodeBounds = true;
bmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.85849);
}
}
注意我的jpg文件的名字是85849
【问题讨论】:
标签: android bitmap bitmapfactory