How to update Android Views after changes?

I have some methods in my view that change some of the shapes that loom when called. In Java, to make sure the component is updated, I would call repaint() . Is there anything that will ensure the correct update of my submission?

I read somewhere that calling invalidate() in the onDraw() method will keep it up-to-date, and therefore I did not need to have something like repaint() in my methods that change the drawings that are being drawn.

Is this right, or is there something else I should do?

EDIT

To add to the example, the method that I call in my opinion is:

 public void setLineThickness(int thickness) { aLineThickness = thickness; if(aLineThicness > 1) //repaint(); - Okay in Java but not in Android } 
+7
source share
1 answer

A call to invalidate () will tell you that he needs to redraw himself (call onDraw) sometime in the future. Therefore, if you change something in your view, such as line thickness, call invalidate () after it. This way, you know that your opinion will eventually be updated.

All your drawing code should be implemented in onDraw (), and your other methods should simply change the state of your view, which will then be used to draw it after calling invalidate ().

+16
source

All Articles