you have declared the id as childWidget and u try to access it by childWidgete..hence the NPE
On Fri, Feb 20, 2009 at 1:48 PM, Meryl Silverburgh < silverburgh.me...@gmail.com> wrote: > > Hi, > > In my layout.xml, I have a child Widget under my custom widget "MyWidget" > > My question is in my java code of my parent widget ("MyWidget"), how > can I get a reference to the child Widget ("MyChildWidget")? > > > > <com.mycompany.widget.MyWidget android:id="@android:id/widget" > android:layout_width="fill_parent" > android:layout_height="wrap_content" > > > <LinearLayout > android:orientation="vertical" > android:layout_width="fill_parent" > android:layout_height="fill_parent"> > > <com.mycompany.widget.MyChildWidget id="@+id/childWidget" > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:gravity="bottom" > /> > </LinearLayout> > </com.mycompany.widget.MyTabWidget> > > > I have tried this, but I get a null pointer: > MyChildWidget childWidget = (MyChildWidget) > this.findViewById(R.id.childWidgete); > > if (childWidget != null) { > > } else { > // always get here... > > } > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---