I was attempting to add a custom view in XML, but I kept getting force
closes. It works fine when I just find the parent and use addView()
so it isn't the code. I'm pretty sure I'm just getting the
constructors wrong. Does anyone have any experience with this?
Here's what I've got:
public class TapPlotDrawer extends View {
//Constructor
public TapPlotDrawer(Context context) {
super(context);
//setup Paint, Canvas etc
}
//Other constructor thats I assume is supposed to work with XML
inflating
public TapPlotDrawer(Context context, AttributeSet attrs) {
super(context, attrs);
//setup Paint, Canvas
}
//final constructor
public TapPlotDrawer(Context context, AttributeSet attrs, int
defStyle) {
super(context, attrs, defStyle);
//setup stuff again
}
}
I also overrode onDraw, onMeasure and onTouchEvent in my source. I
may have done onMeasure wrong but nothing worked when I didn't
override it either. Any suggestions?
--
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