How to access my ViewParent
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?
精彩评论