title: About onDraw method
body: <p>I want to draw rectangle on screen. But I don't run programme. Because, I am writing wrong code. Therefore, I am not writing MainActivity below. Can you help me to use the onDraw method?</p>
  
  <p>Best Regards.</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Deneme.java</p>
  
  <pre><code>public class Deneme extends View {
  
  Paint myPaint;
  
  public Deneme(Context context) {
      super(context);
  
      myPaint = new Paint();
      myPaint.setColor(Color.BLACK);
      myPaint.setStyle(Paint.Style.FILL);
  }
  
  @Override
  protected void  onDraw(Canvas canvas) {
      super.onDraw(canvas);
      Rect ourRect = new Rect();
      ourRect.set(0,0,canvas.getWidth(),canvas.getHeight()/2);
      canvas.drawRect(ourRect,myPaint);
  }
  </code></pre>
  
  <p>}</p>