Hi everyone, I've made a simple countdown timer and I would like to use it as a custom view in my xml layout.
The view works perfectly well if i add it manually like this: this.myTimerView = new TimerView(this); layout.addView(myTimerView); However when I use it in the xml file, the program crashes. This is what i've done: XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/ android" android:id="@+id/layout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/imgv" /> <TextView android:id="@+id/txtv" /> <com.myproject.TimerView android:id="@+id/timer" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout> TimerView class: public class TimerView extends View { // Constructors public TimerView(Context context) { super(context); init(); } public TimerView(Context context, AttributeSet attrs) { super(context, attrs); init(); } @Override protected void onDraw(Canvas canvas) { //code } } What am I doing wrong ? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---