fla888
fla888

Reputation: 67

why surfaceCreated and surfaceDestroyed called several times when set visibility with GONE and continue with VISIBLE?

i found that this codes will cause surfaceCreated and surfaceDestroyed to be called several times:

mSurfaceView.setVisibility(View.GONE);
mSurfaceView.setVisibility(View.VISIBLE);   

could anybody tell me why surfaceCreated and surfaceDestroyed doesn't to be called only once ?

Upvotes: 4

Views: 2755

Answers (1)

Mohsen Afshin
Mohsen Afshin

Reputation: 13436

If you implement SurfaceHolder.Callback and put a logger inside each of surfaceDestroyed, surfaceCreated, surfaceChanged methods, you will see that those two lines will generate the following output:

04-01 12:50:54.688: INFO/app(4842): SurfaceView destroyed!
04-01 12:50:54.688: INFO/app(4842): SurfaceView created!
04-01 12:50:54.718: INFO/app(4842): SurfaceView changed!

Using two breakpoints before and after the calls to setVisibility, just make sure you don't count other logs.

Upvotes: 4

Related Questions