Thursday, June 17, 2010

[android-developers] setContentView of a Custom View

Hello,

My current painting activity is built off of FingerPaint.java from the
API Demos. In my xml I declared the custom view, see below. When I
setContentView(view); everything works fine, but the problem is when I
setContentView(paint_layout.xml) it does not work properly.

///////////PaintActivity///////////
public class Paint extends PaintActivity implements
ColorPickerDialog.OnColorChangedListener {

private Paint mPaint;
private PaintView view;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
view = new PaintView(this);
setContentView(view);

//Set mPaint code
}

public class PaintView extends View {
//PaintView code
}
//Paint code
}

///////////paint_layout.xml///////////
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/paint"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<com.myname.appname.PaintView
android:id="@+id/PaintView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

<!-- other buttons and text -->
</FrameLayout>

Can anyone inform me of why exactly? Am I missing an attribute for the
custom layout in the xml?

Thank you!

Matt.

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment