[英]How to set image on canvas from resource class
我尝试从我在resource.java上声明的drawable设置位图图像。 当我单击下一步按钮时,它将显示另一幅我可以绘制的图像。 这是正确的代码吗?
bmp = BitmapFactory.decodeResource(getResources(), Resource.capitalStoke[DrawingActivity.this.position]);
还是要添加?
这是我的resource.java:
public class Resource {
public static String DRAWING_ALPHABET;
public static Integer[] capitalStoke;
Integer[] alphabetCapital;
Integer[] alphabetSound;
Integer[] alphabetImage;
static {
DRAWING_ALPHABET = "alphabet";
capitalStoke = new Integer[]{Integer.valueOf(R.drawable.capital_letters_stroke_01),
Integer.valueOf(R.drawable.capital_letters_stroke_02),
Integer.valueOf(R.drawable.capital_letters_stroke_03),};
}
是否可以使用bitmapfactory从此处检索图像?如果可能,该怎么办?
正确遵循此方法如何从resource设置位图 。
在我看来,更好的主意是使用通用方式-就像R.id.drawable_1;
这样的R.id.drawable_1;
。 您始终可以将跟随ID存储在数组或列表中以进行迭代。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.