Using java Syntax Highlighting
- package com.poff.android.drawtest;
- import android.app.Activity;
- import android.content.Context;
- import android.graphics.Bitmap;
- import android.graphics.Canvas;
- import android.graphics.Paint;
- import android.graphics.drawable.Drawable;
- import android.os.Bundle;
- import android.view.View;
- import android.view.Window;
- public class DrawTest extends Activity {
- MyView mview;
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- mview = new MyView(this);
- setContentView(mview);
- }
- public class MyView extends View {
- private Drawable playerImage;
- private int playerWidth;
- private int playerHeight;
- public MyView(Context c) {
- super(c);
- playerImage = c.getResources().getDrawable(R.drawable.theplayer);
- playerWidth = playerImage.getIntrinsicWidth();
- playerHeight = playerImage.getIntrinsicHeight();
- }
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- canvas.save();
- playerImage.draw(canvas);
- canvas.restore();
- }
- }
- }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
What am I doing wrong in this code? playerImage does not show up anywhere on the screen. Since I'm working on a game, is a Drawable the correct type to be used here? Or should I use ImageView? I plan on using animations, if that makes a difference.
Also, is there a link to a good tutorial that explains the XML resource files? Is there a tutorial on having multiple views at once (Tileview + other views)?

