The problem was in my widget, I had the correct constructor (Context context AttributeSet attr); HOWEVER - super(context) was being called - not super(context, attr). Once I fixed that, life was better.
On Sep 15, 3:21 am, bob <b...@coolgroups.com> wrote: > Actually, this is returning null: > > StatsTable st = (StatsTable) findViewById(R.id.hello); > > Any idea why? > > On Sep 14, 7:24 pm, Mark Murphy <mmur...@commonsware.com> wrote: > > > > > > > > > If StatsTable is in the com.coolgroups.bob package, you would use: > > > <com.coolgroups.bob.StatsTable android:id="@+id/hello" ... /> > > > Note that you would need a different (additional) constructor, one > > that takes an AttributeSet as the second parameter. See my ColorMixer > > custom widget: > > >https://github.com/commonsguy/cwac-colormixer > > > On Wed, Sep 14, 2011 at 8:21 PM, bob <b...@coolgroups.com> wrote: > > > So, I created my own View subclass like this: > > > > public class StatsTable extends View { > > > > public StatsTable(Context context) { > > > super(context); > > > // TODO Auto-generated constructor stub > > > } > > > > @Override > > > public void onDraw(Canvas canvas) { > > > canvas.drawARGB(255, 1, 0, 0); > > > } > > > > } > > > > Anyone know what I have to do to reference this in my layout XML? > > > > -- > > > 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 > > > -- > > Mark Murphy (a Commons > > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > > Android 3.1 Programming Books:http://commonsware.com/books -- 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