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

Reply via email to