我正在尝试在屏幕上绘制一个简单的 .png 文件。我正在使用以下代码:
public class EditMindMapActivity extends Activity {
private Button HomeButton;
private Button SaveButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_mind_map);
//creating dummy array:
List<String> mindMapArrayListLabels = new ArrayList<String>();
int mindMapArrayListImgs[] = new int[100]; //length 100 is arbitrary
mindMapArrayListLabels.add("Schedule");
mindMapArrayListImgs[0] = R.drawable.pyr01;
mindMapArrayListLabels.add("Stuff01");
mindMapArrayListImgs[1] = R.drawable.tube01;
mindMapArrayListLabels.add("Stuff02");
mindMapArrayListImgs[2] = R.drawable.cone01;
//draw the first image to screen
View view01 = new View(this);
//find relative layout, attach view to it.
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.RelativeLayout01);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
relativeLayout.addView(view01,lp);
Canvas canvas01 = new Canvas();
canvas01.drawBitmap(BitmapFactory.decodeResource(getResources(), mindMapArrayListImgs[0]), 10, 10, null);
view01.draw(canvas01);
}
}
以上没有做任何事情 - 屏幕显示为空白。我想在屏幕上显示图像 R.drawable.pyr01。