title: Adding view onto an activity
body: <p>If I want to add a button in this class so that I can call the <code>onclicklistener</code>, how should I do it?</p>
  
  <pre><code>public class GameView extends View {
      Path circle;
      Paint cPaint;
      Paint tPaint;
      String z;
      int i = 65, strt, arc, leftx, topy, rightx, bottomy, maxx, maxy;
      boolean flag1, flag2, flag3;
      double n1, n2;
      int n, n3 = 180,n4,n5 = 90;
      float f1 = 180, f2 = 90;
      Button b1;
      Random r = new Random();
      RectF  oval;
  
      public GameView(Context context) {
          super(context);
  
          leftx = 0;
          topy = 60;
          rightx = 150;
          bottomy = 120;
  
          z = String.valueOf(Character.toChars(i));
  
          cPaint = new Paint();
          cPaint.setColor(Color.RED);
  
          strt = 45;
          arc = 315;
  
          n1 = Math.random() * 600;
          Log.d("random", z);
  
          if (flag2 == false)
              new DrawThread(this);
  
          // cPaint.setStrokeWidth(2);
          tPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
          tPaint.setStyle(Paint.Style.FILL_AND_STROKE);
          tPaint.setColor(Color.BLACK);
          float scale = getResources().getDisplayMetrics().scaledDensity;
          tPaint.setTextSize(20 * scale);
      }
  
      public void onSizeChanged(int w,int h,int oldh,int oldw) {
          maxx = oldw;
          maxy = oldh;
      }
  
      //@Override
      protected void onDraw(Canvas canvas) {
          // Drawing commands go here
          oval = new RectF(leftx,topy,rightx,bottomy);
          canvas.drawArc(oval, strt, arc, true, cPaint);
          while (i &lt; 90)  {
              canvas.drawText(String.valueOf(Character.toChars(i)),f1,f2, tPaint);
              break;
          }
      }
  }
  </code></pre>