尝试在空对象引用上调用虚拟方法'void android.widget.ImageView.setImageResource(int)'



我正在尝试用图片(png(填充此数组,但出现错误..有什么建议吗?

//body part images
private ImageView[] bodyParts;

bodyParts = new ImageView[numParts];
bodyParts[0].setImageResource(R.drawable.stage1);
bodyParts[1].setImageResource(R.drawable.stage2);
bodyParts[2].setImageResource(R.drawable.stage3);
bodyParts[3].setImageResource(R.drawable.stage4);
bodyParts[4].setImageResource(R.drawable.stage5);

出现此错误是因为数组中没有图像视图,您在空对象上使用方法setImageResource(( ,数组正文部分不包含任何图像视图

相关内容

最新更新