Umm, declare a theme with whatever attributes you need (using declare-styleable) and get the values in the constructor from the AttributeSet? I believe that's how it's supposed to be done, all the framework support is already there.
-- Kostya Vasilyev -- http://kmansoft.wordpress.com 13.01.2011 22:04 пользователь "Brill Pappin" <[email protected]> написал: > I can't set it after inflate because I'm trying to access it in the constructor. > > I did try setting it in xml, but I only get null back (may be a bug, but I haven't investigated that). > > - Brill Pappin > > Sent from my Android device > > Brad Gies <[email protected]> wrote: > >> >>Can't you just set the tag when you inflate it? Or set the tag in the >>.xml file? >> >>Sincerely, >> >>Brad Gies >>----------------------------------------------------------------------- >>Bistro Bot - Bistro Blurb >>http://bgies.com http://nocrappyapps.com >>http://bistroblurb.com http://forcethetruth.com >>http://ihottonight.com >>----------------------------------------------------------------------- >>Everything in moderation, including abstinence (paraphrased) >> >>Every person is born with a brain... Those who use it well are the successful happy ones - Brad Gies >> >>Adversity can make or break you... It's your choice... Choose wisely - Brad Gies >> >>Never doubt that a small group of thoughtful, committed people can >>change the world. Indeed. It is the only thing that ever has - Margaret Mead >> >> >>On 13/01/2011 10:28 AM, Brill Pappin wrote: >>> Ok, this is the same problem as my last post, but i'm not getting any >>> traction with it, so i'm looking for another method solve the problem. >>> >>> All i need to do is identify the xml resource a view was inflated >>> from, in the views constructor. >>> >>> I've tried android:tag which does not seem to be able to do it in this >>> case (I only ever get null back from getTag()). >>> >>> The situation is that I have a single java class extending view. >>> I inflate one of many XMLs into the view and I need to be able to >>> change stylesheets based upon which xml resource i'm loading. >>> >>> Does anyway one a method of doing this? >>> >>> My last fallback is to use some sort of static class that I can set >>> the xml resource on for the entire app, then try and look at the id to >>> determine which resource I loaded. I'm reluctant to do that because >>> it's kludgy and I think its far more likely to introduce bug etc. Note >>> that I haven't tried to do this yet, but it should work based on how >>> java behaves. >>> >>> I just can't believe that there is no way to a view to know what XML >>> resource it was inflated from! >>> >>> - Brill Pappin >>> -- >>> 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]<android-developers%[email protected]> >>> For more options, visit this group at >>> http://groups.google.com/group/android-developers?hl=en >> >>-- >>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]<android-developers%[email protected]> >>For more options, visit this group at >>http://groups.google.com/group/android-developers?hl=en > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- 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

