DavidN wrote: > I was getting a null exception in my onCreate() until I found that I > had to move that method call _after_ the > setContentView(R.layout.main), just in case anyone else has this same > problem. Don't understand the reason why, but just in case anyone gets > this (and then googles for it), this is a possible cause.
The reason why is that the widgets don't exist yet. The findViewById() method walks the tree of Views (widgets and layouts) that make up the activity. However, those aren't determined until after setContentView() is called. Before setContentView(), the activity has no Views, and so findViewById() will return null. -- Mark Murphy (a Commons Guy) http://commonsware.com Warescription: All titles, revisions, & ebook formats, just $35/year --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

