title: DrawPath in android Custom View
body: <p>I have a closed path, and I want to fill it with one color (white) and put an edge of another color (red) around it. I thought a Custom View class would allow me to achieve this purpose:</p>
  
  <pre><code>public class StrokeFill extends View{
  private Path shapePath;
  private Paint strokePaint;
  private Paint fillPaint;
  
  
  public StrokeFill(Context context, Path path) {
      super(context);
      shapePath = path;
      fillPaint.setColor(android.graphics.Color.WHITE);
      fillPaint.setStyle(Paint.Style.FILL);
      fillPaint.setStrokeWidth(0);
      strokePaint.setColor(android.graphics.Color.RED);
      strokePaint.setStyle(Paint.Style.STROKE);
      strokePaint.setStrokeWidth(3);
      // TODO Auto-generated constructor stub
  }
  
  protected void onDraw(Canvas canvas) {
      // TODO Auto-generated method stub
      //canvas.drawColor(Color.BLACK);
      super.onDraw(canvas);
      canvas.drawPath(shapePath, fillPaint);
      canvas.drawPath(shapePath, strokePaint);
  }
  }
  </code></pre>
  
  <p>In my main Activity, I just did this (no XML layout file):</p>
  
  <pre><code>setContentView(new StrokeFill(this, testpath));
  </code></pre>
  
  <p>testpath is a path I defined in the Activity. It is valid because I was able to draw it when I define a PathShape using it.
  But in this case, Eclipse is giving me the error java.lang.NullPointerException. I tried defining the custom view in the XML layout but that doesn't work either. Working with shapes in android has been very frustrating so far, so it will be great if someone can help!</p>