You're a genius and a savior! This problem was driving me crazy. Your solution is much better. I didn't know layout XML files would support a class I created.
Thanks! On Feb 22, 3:34 pm, Odessa Silverberg <[email protected]> wrote: > On Feb 21, 7:18 am, gymshoe <[email protected]> wrote:> Proposed code: > > Public class MyGallery extends Gallery{ > > Public MyGallery(Context ctx, AttributeSet attrSet) { // code for > > constructor } > > // more code for subclass} > > > MyGallery myGallery = (Gallery) findViewById(R.id.gallery); // but > > this doesn’t work… > > MyGallery myGallery = (MyGallery) findViewById(R.id.gallery); // and > > this doesn’t work… > > That's because you have Gallery in your XML layout file i.e. > <Gallery ... /> > > Instead you need to specify your own class in the XML file inclding > full package name. > > For example > > <org.odessa.myprogramm.MyGallery ..../> > > Now you could get a refference by using > MyGallery myGallery = (MyGallery) findViewById(R.id.gallery); > > Because now both have the same class. > > > If it is possible, simplistically, I would like to do: > > Gallery gallery = (Gallery) findViewById(R.id.gallery); > > MyGallery myGallery = new MyGallery(this, gallery.someMethodToGetAttSet > > ()); > > That would just make it to complicated imho. Simply use your full > class name to your gallery class as tag in your layout XML file --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" 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-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

