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

社会主义新天地 提交于 2020-01-02 07:23:07

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/15729782/why-surfacecreated-and-surfacedestroyed-called-several-times-when-set-visibility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!