title: Can I do addView in onDraw of MyLayout?
body: <p>I am new for android. I want to add image button in onDraw. I wonder if I can do like this. I don't have compile error. But simulator says, "Unfortunately MyApp has stopped."
  My second question is how can I add button at x, y location in screen?
  There is no location parameters in addView.</p>
  
  <pre><code>protected class MyLayout extends LinearLayout {
      ImageButton button;
      public MyLayout(Context context) {
          super(context);
          setWillNotDraw(false);
          button = new ImageButton(context);
          button.setImageBitmap(buttonBitmap); // buttonBitmap is loaded in onCreate
      }
      public void onDraw(Canvas canvas) {
          addView(button);
      }
  }
  </code></pre>