Custom layout with WindowManager
<p>For some reason, I keep getting an Error inflating Class message because I'm trying to implement</p>

<p>Caused by: java.lang.NullPointerException
at pap.crowslanding.GameView.(GameView.java:49)</p>

<p>Line 49 is this </p>

<pre><code>WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
</code></pre>

<p>I am doing it this way because I am not in an Activity, any suggestions?</p>

<p>EDIT:</p>

<pre><code>public class GameView extends SurfaceView {
static final long FPS = 10;
public Bitmap bmp;
public SurfaceHolder holder;
public LoopGameThread loopGameThread;
public static Sprite sprite;
public LayoutInflater inflater;

//maze variables
  public int width;                 
  public int height;
  private float cellWidth;
  private boolean[][] north;     // is there a wall to north of cell i, j
  private boolean[][] east;
  private boolean[][] south;
  private boolean[][] west;
  private boolean[][] visited;
  private double size;
  boolean done = false;

  Display display = new 
  Paint paint = new Paint();




//maze variables
   public GameView(Context context) {
    super(context);
   WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
   Display display = wm.getDefaultDisplay();
   Point screenSize = new Point();
    display.getSize(screenSize);
    int width = screenSize.x;
    int height = screenSize.y;

}
public GameView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // TODO
}

public GameView(Context context, AttributeSet attrs) {

    super(context, attrs);

    //maze variables
    initVars(attrs);
    initMaze();
    generate(1, 1);
    //maze variables
    loopGameThread = new LoopGameThread(this);
    holder = getHolder();

    holder.addCallback(new Callback() {

        @Override
        public void surfaceChanged(SurfaceHolder holder, int format,
                int width, int height) {

        }

        @Override
        public void surfaceCreated(SurfaceHolder holder) {
            loopGameThread.isStart(true);
            loopGameThread.start();
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {

        }

    });

    bmp = BitmapFactory.decodeResource(getResources(), R.drawable.crow);
    sprite = new Sprite(this, bmp);

}


//MAZE VARIABLES

private void initVars(AttributeSet attrs) {
      //requires display variables
  }
</code></pre>

<p>Then within my initVars, I need to use those display variables</p>

<p>EDIT 2 :</p>

<pre><code>package pap.crowslanding;


import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Bundle;
import android.os.Handler;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnTouchListener;
import android.widget.Button;

public class Game extends MainActivity{
static boolean pressedUp = false;
 protected static GameView gameV;


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.tester1);


    Button moveLeft = (Button) findViewById(R.id.button1);
    gameV = (GameView)findViewById(R.id.game_view);



    moveLeft.setOnTouchListener(new View.OnTouchListener() {

        private Handler mHandler;

        @Override public boolean onTouch(View v, MotionEvent event) {
            switch(event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                if (mHandler != null) return true;
                mHandler = new Handler();
                mHandler.postDelayed(mAction, 100);
                break;
            case MotionEvent.ACTION_UP:
                if (mHandler == null) return true;
                mHandler.removeCallbacks(mAction);
                mHandler = null;
                break;
            }
            return false;
        }

        Runnable mAction = new Runnable() {
            @Override public void run() {
                System.out.println("Performing action...");
                mHandler.postDelayed(this, 100);
                GameView.sprite.movementGo();
            }
        };

    });
}       
</code></pre>

<p>}</p>
