Dear all, I have a custom view that draw a rounded rectangle. This view is clickable. I would like to change the color of the inner rectangle when the view is clicked (to act like a button)
So I created a swapColor() method inside my custom view : public void swapColor() { innerPaint.setColor(Color.CYAN); this.invalidate(); // I tried postInvalidade try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } setColors(); //restore initial colors invalidate(); } I call this method in the onClick associated with the view. But this method does not work (but the sleep(500) is called, so I know I am entering it). The onDraw et onDrawDispatch are the same and are given below: protected void dispatchDraw(Canvas canvas) { RectF drawRect = new RectF(); drawRect.set(1, 1, getMeasuredWidth() - 2, getMeasuredHeight() - 2); canvas.drawRoundRect(drawRect, 5, 5, innerPaint); canvas.drawRoundRect(drawRect, 5, 5, borderPaint); super.dispatchDraw(canvas); } protected void onDraw(Canvas canvas) { RectF drawRect = new RectF(); drawRect.set(1, 1, getMeasuredWidth() - 2, getMeasuredHeight() - 2); canvas.drawRoundRect(drawRect, 5, 5, innerPaint); canvas.drawRoundRect(drawRect, 5, 5, borderPaint); super.onDraw(canvas); } Thanks for your help !! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---