Activity.findViewById returning null sporadically
From the crash logs that I am getting from the Android market, I can see that some of my users are getting Force Closes caused by NullPointerExceptions when my code tries to access views that are in my application. In one example, my activity makes a call to findViewById() in onCreate() after I call setContentView(). I get an NPE whe开发者_Python百科n I try to access the view after the call to findViewById() (still in onCreate). What has me really scratching my head is that this does not happen all of the time (in fact most of the time the code acts as I would expect), but enough to have me concerned.
I could add code to always check for null and avoid the NPE, but I would like to understand what could be causing the sporadic behavior.
Does anyone know what could be causing this?
Rename that view may be you can find the view as expected.
精彩评论