0

I know that onDraw() is not being called by SurfaceView. Instead, the drawing is done by a separate thread. Is there any way to know each time it is being redrew/updated?

XterNalz
  • 325
  • 1
  • 5
  • 10

2 Answers2

2

check this answer, you could simple add setWillNotDraw(false) to receive the onDraw() callback

Community
  • 1
  • 1
jaredzhang
  • 1,158
  • 8
  • 12
-1

Perhaps you could create a custom class that extends whatever view you are using. You could then overwite onDraw() and get it to callback to your main activity (pass it to your extended view)

class mButton extends Button {
   private Activity ownerActivity;

   public void setOwner(Activity pA) {
      ownerActivity = pA;
   }

   @override
   public void onDraw() {
      super.onDraw();
      ((MainActivity) ownerActivity).callback();
   }
}

Or something along those lines...

AC Arcana
  • 366
  • 2
  • 10