title: Android - I want... after click button, drawing image in canvas
body: <p>I click dice button in arenalayout.xml (this xml is displayed by 'ArenaLayout' class). But canvas doesn't draw char 2.I want to... if I click dice button then I draw char 2. </p>
  
  <p>Note : After I click dice button, value of 'haveFirstDiced' variable in Arena class change to TRUE. There's condition inside of onDraw in 'Arena' class. . . if 'haveFirstDiced' variable have TRUE value then drawing char 2. </p>
  
  <pre><code>     public class ArenaLayout extends Activity {
  
          private Arena arena;  
          ImageButton diceButton;
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.arena_layout);
              diceButton = (ImageButton) findViewById(R.id.dice);
              dice();
          }
  
          private void dice() {
              diceButton.setOnClickListener(new OnClickListener() {
                  @Override
                  public void onClick(View arg0) {
                      arena.dicing();
                  }
              });
          }
  }
  </code></pre>
  
  <p>This is 'Arena' class :</p>
  
  <pre><code> public class Arena extends View{
  
      private Paint p;
      private Handler threadHandler = new Handler();
      private Bitmap char1;
      private float x = 20, y = 300;
      Canvas c;
      boolean haveFirstDiced = false; 
  
      public Arena(Context context, AttributeSet aSet) {
          super(context, aSet);
          p = new Paint();
       }
  
      public void dicing() {
          new Thread(new XXX()).start();
      }
  
        @Override
      synchronized public void onDraw(Canvas canvas) {
        char2 = BitmapFactory.decodeResource(getResources(), R.drawable.char_2);    
        if(haveFirstDiced == true) {
                canvas.drawBitmap(char2,x,y,null);
            }
      }
  
     class XXX implements Runnable { 
         @Override
         public void run() {
                 threadHandler.post(new Runnable() {
                     @Override
                     public void run() {
                         haveFirstDiced = true;      
                     }
                 });
             }
         }
  
  
    }
  </code></pre>