我发现这些代码会导致几次调用surfaceCreated和surfaceDestroyed:
mSurfaceView.setVisibility(View.GONE);
mSurfaceView.setVisibility(View.VISIBLE);
有人可以告诉我为什么不会只调用一次surfaceCreated和surfaceDestroyed吗?
答案 0 :(得分:4)
如果您实施SurfaceHolder.Callback
并在每个surfaceDestroyed
,surfaceCreated
,surfaceChanged
方法中放入记录器,您会看到这两行将生成以下输出:
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!
在调用setVisibility
之前和之后使用两个断点,只需确保不计算其他日志。