Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Redrawing a specific view inside a layout

I have a vertically aligned LinearLayout which contains a TextView, my own custom view class, and i'm hoping to put an ad at the bottom.

I'm drawing objects in my custom view class (that extends View), but it does not get updated to the screen unless i call setContentView(R.layout.myview), but this resets my TextView to the default text (what is stored in the xml file) which i don't want, and i assume it would redraw a new ad as well... annoying.

Is there a way i can redraw/refresh my custom View to the screen without affecting my textview or whatever else i may have on my layout?

like image 424
sil Avatar asked Oct 11 '22 16:10

sil


1 Answers

How about View.invalidate()?

From the reference:

Note that the framework will not draw views that are not in the invalid region.

To force a view to draw, call invalidate().

like image 88
trojanfoe Avatar answered Oct 20 '22 10:10

trojanfoe