开发者

How to access my ViewParent

开发者 https://www.devze.com 2023-03-29 16:36 出处:网络
I have a glSurfaceView called during onCreate which is inside a FrameLayout. In my glSurfaceView, I want to toggle a temp开发者_JAVA技巧orary loading screen by using addView on the FrameLayout...but i

I have a glSurfaceView called during onCreate which is inside a FrameLayout. In my glSurfaceView, I want to toggle a temp开发者_JAVA技巧orary loading screen by using addView on the FrameLayout...but im not sure how to access that variable to do so. Any suggestions?


Since GLSurfaceView is a descendant of View, you should be able to use getParent() to get the ViewParent (FrameLayout in this case). However, I would advise against this general approach. You are implementing controller logic inside of a view class, which creates poor encapsulation. Why not implement this logic in an Activity instead and preserve the MVC design pattern already in use in the Android SDK?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号