在res文件夹中有自动生成的drawable-hdpi文件夹, 其中有一个jpeg.文件。我先要获取它的ID时参考资料上写"R.drawable.myimage" ,我用完后报错误: "cannot be resolved to a variable"
代码:
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