Look at the logcat output... It should tell you why your app is crashing. Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware
On Tue, Aug 28, 2012 at 7:44 AM, Satya Komatineni < satya.komatin...@gmail.com> wrote: > Victor, > I am not entirely sure. But I can suggest a couple of experiments to > debug. May be inheriting a View directly is too simplisitic. Try > inheriting a TextView first. And if it works then you can look at what > other base methods of the "View" you will need to inherit. > > Take a look at this item from the docs > > http://developer.android.com/training/custom-views/custom-drawing.html > > to see what other methods you need to override. > > Also if you are intending to use some custom attributes you may want > to look at some detailed notes I have gathered at > > http://satyakomatineni.com/item/4169 > > This goes into how attrs.xml and declare styleables work. > > Also let me know what you find. > Thanks > Satya > http://satyakomatineni.com/android/training > http://satyakomatineni.com > http://androidbook.com > http://twitter.com/SatyaKomatineni > On Mon, Aug 27, 2012 at 2:09 PM, Victor Reboucas <vcsrebou...@gmail.com> > wrote: > > Hi, I'm new to Android development and I'm trying to implement a custom > view > > to act as a "custom menu button" for my app. > > > > I followed the instructions at > > http://developer.android.com/training/custom-views/create-view.html but > by > > the end of the implementation I get a message saying "Unfortunately > > customviews1 has stopped" and the app just shut's down. > > > > My approach is very simple and I cannot find any reference about solving > > this basic problem. Here's what I'm doing: > > > > 1. create a new Android project in Eclipse named "customviews1" > > > > 2. I run the project and it shows a "Hello World" TextView on the > > "activity_main.xml" layout file > > > > 3. I add a new class that extends "View" to the "src" folder of the > project: > > > > public class MyCustomView extends View { > > > > public MyCustomView(Context context, AttributeSet attrs) { > > super(context, attrs); > > } > > > > } > > > > 4. I remove the "TextView" from activity_main.xml and add a > "customview1" to > > it: > > > > > > <RelativeLayout xmlns:android=" > http://schemas.android.com/apk/res/android" > > xmlns:tools="http://schemas.android.com/tools" > > android:layout_width="match_parent" > > android:layout_height="match_parent"> > > > > <com.example.customviews1.MyCustomView android:id="@+id/myCustomView1" /> > > </RelativeLayout> > > > > 5. I run the app again and I got the message saying "Unfortunately > > customviews1 has stopped" and the app shuts down. > > > > > > Is there any code I'm missing here? > > > > > > Thanks for any clue, > > Regards, > > Victor Reboucas > > > > > > > > > > > > > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to android-developers@googlegroups.com > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com > > For more options, visit this group at > > http://groups.google.com/group/android-developers?hl=en > > > > -- > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en