Displaying a custom view in a layout
<p>I currently have a class called clientActivity that contains a finger paintig activity that draws onto a canvas, the class has a extension of View Called MyView. I want to make it so that the canvas appears in a relative layout on my xml chat layout.</p>

<p>This is the class ClientActivity</p>

<pre><code>public class ClientActivity extends GraphicsActivity
implements ColorPickerDialog.OnColorChangedListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(new MyView(this));
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(Color.BLACK);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(20);

    mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 },
            0.4f, 6, 3.5f);

    mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL);

}

private Paint       mPaint;
private MaskFilter  mEmboss;
private MaskFilter  mBlur;

public void colorChanged(int color) {
    mPaint.setColor(color);
}


public class MyView extends View {

    ClientNetwork net = new ClientNetwork();

    private static final float MINP = 0.25f;
    private static final float MAXP = 0.75f;

    private Bitmap  mBitmap;
    private Canvas  mCanvas;
    private Path    mPath;
    private Paint   mBitmapPaint;

    public MyView(Context c) {
        super(c);

        mPath = new Path();
        mBitmapPaint = new Paint(Paint.DITHER_FLAG);
        Thread fred = new Thread(net);
        fred.start();
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);

        mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
        mCanvas = new Canvas(mBitmap);



    }
</code></pre>

<p>My chat.xml looks like this.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:weightSum="1"&gt;

&lt;RelativeLayout android:id="@+id/relativeLayout3"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_weight="0.83"&gt;

&lt;com.DrawTastic.ClientActivity android:id="@+id/MyView1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"/&gt;


&lt;/RelativeLayout&gt;

&lt;ListView 
android:id="@+id/listView"
    android:layout_width="match_parent" 
    android:layout_height="152dp" android:layout_weight="0.17"&gt;
    &lt;/ListView&gt;



    &lt;RelativeLayout 
    android:id="@+id/relativeLayout2"
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true"&gt;


        &lt;EditText 
        android:layout_width="232dp"
            android:layout_alignParentTop="true" 
            android:layout_alignParentLeft="true"
            android:layout_height="wrap_content" 
            android:id="@+id/input"&gt;
            &lt;/EditText&gt;


        &lt;Button 
        android:layout_width="wrap_content"
            android:layout_alignParentTop="true" 
            android:layout_marginRight="16dp"
            android:layout_alignParentRight="true" 
            android:text="Send"
            android:onClick="sent" android:id="@+id/send" 
            android:layout_height="wrap_content"&gt;
            &lt;/Button&gt;

    &lt;/RelativeLayout&gt;
</code></pre>

<p></p>

<p>I just need the canvas to appear in the the chat.xml inside one of the layouts so I can lay a listview beneath it.</p>

<p>Any help is greatly appreciated!</p>

<p>Thanks</p>

<p>EDIT: Stack trace.</p>

<pre><code>03-22 15:32:21.310: ERROR/AndroidRuntime(1301): FATAL EXCEPTION: main
03-22 15:32:21.310: ERROR/AndroidRuntime(1301): java.lang.RuntimeException: Unable to     start activity ComponentInfo{com.DrawTastic/com.DrawTastic.GameActivity}:     android.view.InflateException: Binary XML file line #8: Error inflating class     com.DrawTastic.ClientActivity.MyView
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at         android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at     android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
       03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.os.Looper.loop(Looper.java:123)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.app.ActivityThread.main(ActivityThread.java:3683)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at java.lang.reflect.Method.invokeNative(Native Method)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at java.lang.reflect.Method.invoke(Method.java:507)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at dalvik.system.NativeStart.main(Native Method)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.DrawTastic.ClientActivity.MyView
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.app.Activity.setContentView(Activity.java:1657)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at com.DrawTastic.GameActivity.onCreate(GameActivity.java:13)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     ... 11 more
03-22 15:32:21.310: ERROR/AndroidRuntime(1301): Caused by: java.lang.ClassNotFoundException: com.DrawTastic.ClientActivity.MyView in loader     dalvik.system.PathClassLoader[/data/app/com.DrawTastic-2.apk]
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.view.LayoutInflater.createView(LayoutInflater.java:471)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
03-22 15:32:21.310: ERROR/AndroidRuntime(1301):     ... 21 more
</code></pre>
