Clickable image, result -> show / hide another image?

All your problems with Audio, Video and Images.

Clickable image, result -> show / hide another image?

Postby xtreme » Sat May 15, 2010 8:43 pm

The code below draws my png images. Now I want to get left_btn clickable. When you click on the image left_btn should left_foot be hidden and another png image appear. How do you make these? I am not useing layout -> main.xml

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class DrawView extends View implements OnClickListener {
  3.  
  4.    private ColorBall game, left_btn, right_btn, head_body, left_foot, right_foot, left_arm, right_arm, left_hand, right_hand;
  5.  
  6.    
  7.  
  8.     public DrawView(Context context) {
  9.  
  10.         super(context);
  11.  
  12.         setFocusable(true); //not yet necessary, but you never know what the future brings
  13.  
  14.        
  15.  
  16.         // declare each ball with the ColorBall class
  17.  
  18.        
  19.  
  20.         game = new ColorBall(context,R.drawable.test1);
  21.  
  22.         left_btn = new ColorBall(context,R.drawable.left_btn);
  23.  
  24.         right_btn = new ColorBall(context,R.drawable.right_btn);
  25.  
  26.         head_body = new ColorBall(context,R.drawable.head_body);
  27.  
  28.         left_foot = new ColorBall(context,R.drawable.left_foot);
  29.  
  30.         right_foot = new ColorBall(context,R.drawable.right_foot);
  31.  
  32.         left_arm = new ColorBall(context,R.drawable.left_arm);
  33.  
  34.         right_arm = new ColorBall(context,R.drawable.right_arm);
  35.  
  36.         left_hand = new ColorBall(context,R.drawable.left_hand);
  37.  
  38.         right_hand = new ColorBall(context,R.drawable.right_hand);
  39.  
  40.            
  41.  
  42.     }
  43.  
  44.  
  45.  
  46.  
  47.  
  48.   @Override protected void onDraw(Canvas canvas) {
  49.  
  50.                 canvas.drawBitmap(game.getBitmap(), 0, 0, null);
  51.  
  52.                 canvas.drawBitmap(left_btn.getBitmap(), 45, 206, null);
  53.  
  54.                 canvas.drawBitmap(right_btn.getBitmap(), 397, 206, null);
  55.  
  56.                 canvas.drawBitmap(head_body.getBitmap(), 230, 132, null);
  57.  
  58.                 canvas.drawBitmap(left_foot.getBitmap(), 225, 185, null);
  59.  
  60.                 canvas.drawBitmap(right_foot.getBitmap(), 250, 185, null);
  61.  
  62.                 canvas.drawBitmap(left_arm.getBitmap(), 205, 165, null);
  63.  
  64.                 canvas.drawBitmap(right_arm.getBitmap(), 260, 165, null);
  65.  
  66.                 canvas.drawBitmap(left_hand.getBitmap(), 190, 145, null);
  67.  
  68.                 canvas.drawBitmap(right_hand.getBitmap(), 290, 145, null);
  69.  
  70.  
  71.  
  72.     invalidate();
  73.  
  74.     }  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4
xtreme
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri May 14, 2010 1:12 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 9 guests