Android - Can I force a call to View.onSizeChanged when starting an activity from another activity
I have an activity that is basically just a splash screen. A button in this activity starts a new activity which has a view in it that depends on the View.onSizeChanged
callback to setup critical resources, (it needs the size values to set up a grid of tiles).
The first time i run the app, everything works fine. The onSizeChanged
callback is called at some point after the view is created, and the tile grid gets set up correctly. If I then hit the back button, (which takes me back to the splash screen activity and cleans up/destroys the other activity), things are still ok. From the splash screen, (without exiting the app altogether), if I then click the 开发者_C百科start button again, I get a null pointer exception when the first tile is trying to be set, (because the grid is null, because View.onSizeChanged
was not called).
Is there a way to, or is it even appropriate to, force a guaranteed call to View.onSizeChanged
every time the second activity is started, and hence the view needing it is created?
Does this make enough sense without posting the code?
精彩评论