You probably didn't override the correct constructors. Views inflated from XML are instanciated using the constructors that take an AttributeSet argument.
On Mon, Jul 12, 2010 at 12:30 PM, Mark Murphy <[email protected]> wrote: > Use adb logcat, DDMS, or the DDMS perspective in Eclipse to examine > LogCat and see the Java stack trace associated with your error. > > On Fri, Jul 9, 2010 at 4:51 PM, David Fabijan <[email protected]> wrote: >> This is probably a common newbie problem, but I have not been able to >> find a solution anywhere. >> >> I have created a simple class named Panel which extends the >> SurfaceView class and does some drawing in the onDraw method. When I >> use it from the code it works fine. For example this works as >> expected: >> >> >> public void onCreate(Bundle savedInstanceState) { >> super.onCreate(savedInstanceState); >> setContentView(new Panel(this)); >> .... >> >> >> However when I try adding this component from an xml layout the >> program crashes: >> >> XML file (main.xml): >> >> <?xml version="1.0" encoding="utf-8"?> >> <org.anddev.Panel >> android:id="@+id/panel" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> xmlns:android="http://schemas.android.com/apk/res/android" >> /> >> >> Code: >> >> public void onCreate(Bundle savedInstanceState) { >> super.onCreate(savedInstanceState); >> setContentView(R.layout.main); >> .... >> >> >> Error msg: >> >> Sorry! >> >> The application Test >> (process org.anddev) has >> stopped unexpectedly. >> Pleas try again. >> >> >> I can not figure out why the same class works when created in one way >> and doesn't work when created in another. Help will be greatly >> appreciated. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://github.com/commonsguy > http://commonsware.com/blog | http://twitter.com/commonsguy > > Android App Developer Books: http://commonsware.com/books > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

