public class MainActivity extends Activity {

 int count = 0;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
       
        Button line = (Button)findViewById(R.id.btn_line);
        Button circle = (Button)findViewById(R.id.btn_circle);
        Button rect = (Button)findViewById(R.id.btn_rect);
        Button text = (Button)findViewById(R.id.btn_txt);
       
        View v = (View)findViewById(R.id.action_settings);
       
        LinearLayout ii = (LinearLayout)findViewById(R.id.LinearLayout1);
       
        CustomView cv = new CustomView(MainActivity.this, v.getID()); // v를 통해서 버튼값을 넘겨줌
       
        ii.removeViewAt(1); // 1번 레이아웃 삭제
        ii.addView(cv);  // LinearLayout에 cv라는 View를 추가함
       
        line.setListener(ClickListener);
        circle.setListener(ClickListener);
        rect.setListener(ClickListener);
        text.setListener(ClickListener);
    }
   
   
   
    View.Listener ClickListener = new View.Listener(){
     
     public void (View v){
      switch(v.getId()){
      case R.id.btn_line :
       Toast.makeText(MainActivity.this, "Line Toast", Toast.LENGTH_SHORT).show();
       count=0;
       break;
      case R.id.btn_circle :
       Toast.makeText(MainActivity.this,"Circle Toast",Toast.LENGTH_SHORT).show();
       count=1;
       break;
      case R.id.btn_rect :
       Toast.makeText(MainActivity.this, "Rect Toast", Toast.LENGTH_SHORT).show();
       count=2;
       break;
      case R.id.btn_txt :
       Toast.makeText(MainActivity.this, "Text Toast", Toast.LENGTH_SHORT).show();
       count=3;
       break;
      }
     }
    };
   
    public class CustomView extends View{
  
     public CustomView(Context context, int v){
         super(context);
         this.v= v;
        }
     
     public void onDraw(Canvas canvas){ // 그리기를 수행하는 메소드
      canvas.drawColor(Color.LTGRAY);
      Paint pnt = new Paint();
      pnt.setColor(Color.BLUE);
      
      switch(count){
      case 0 :
       pnt.setColor(Color.BLUE);
       canvas.drawLine(20, 10, 200, 50, pnt);
       break;
      case 1 :
       pnt.setColor(Color.RED);
       canvas.drawCircle(100,90,50,pnt);
       break;
      case 2 :
       pnt.setColor(0x800000ff);
       canvas.drawRect(10,100,200,170,pnt);
       break;
      case 3 :
       pnt.setColor(Color.BLACK);
       canvas.drawText("Canvas Text", 10, 200,pnt);
       break;
      }
     }
    }


아까 ?횬님이 불러준 View v = (View)findViewById(R.id.action_settings); 해보구 돌파잉 횬님이 에서 하지 않냐해서 거기다가 저 부분 넣어봤는데 getID()에서 오류가 나구 .. ㅠㅠ 어케 해야댐!! 돕구 삽시다!