我发现这段代码会导致surfaceCreated和surfaceDestroyed被多次调用:
mSurfaceView.setVisibility(View.GONE);
mSurfaceView.setVisibility(View.VISIBLE);
谁能告诉我为什么surfaceCreated 和surfaceDestroyed 不只被调用一次?
我发现这段代码会导致surfaceCreated和surfaceDestroyed被多次调用:
mSurfaceView.setVisibility(View.GONE);
mSurfaceView.setVisibility(View.VISIBLE);
谁能告诉我为什么surfaceCreated 和surfaceDestroyed 不只被调用一次?
如果您在每个, ,方法中实现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
,只需确保不计算其他日志。