I am trying to create a Custom View and display it using a layout
definition in XML.  However whenever the Activity that contains this
Custom View is executed, the application stops and I get Forced close
error.

Here is the CustomView class

public class CustomView extends View
{
        private Paint paint;

        public CustomView(Context _context)
        {
                super(_context);
                paint = new Paint();
                // set's the paint's colour
                paint.setColor(Color.GREEN);
                // set's paint's text size
                paint.setTextSize(25);
                // smooth's out the edges of what is being drawn
                paint.setAntiAlias(true);

        }

        @Override
        protected void onDraw(Canvas canvas)
        {
                super.onDraw(canvas);
                canvas.drawText("Hello World", 5, 30, paint);
                // if the view is visible onDraw will be called at some point
                // in the future
                invalidate();
        }
}

and the entry in main.xml
        <com.jc.test.CustomView
                android:id="@+id/customview"/>
        />

        <TextView
        android:id="@+id/entry"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />

Any help or suggestions??

Thanks

-- 
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

Reply via email to