Ok, I have the following files: attrs.xml, styles.xml, themes.xml Here is my attrs.xml file:
<!-- Attributes --> <attr name="myMainSplashImage" format="reference"/> <declare-styleable name="MainSplash"> <attr name="splashDrawable" format="reference"/> </declare-styleable> Here is my themes.xml file: <style name="Theme.MyCustomTheme" parent="@android:style/ Theme"> <item name="myMainSplashImage">@drawable/splash</item> </style> Here is my styles.xml file: <style name="MainSplash"> <item name="splashDrawable">?attr/myMainSplashImage</item> </style> I have looked at different tutorials and libraries (GreenDroid) to implement the above. So I have basically set my custom attribute to whatever I have defined in my Theme file. This allows me to create different theme files for different projects (as this is a library project). I have assigned the Theme to the entire library project. I dont know if I now have to assign something else to my splash layout file? On Jan 10, 9:53 am, Kostya Vasilyev <kmans...@gmail.com> wrote: > Where and how are you setting attribute values? > > Your call to getStylableAttributes is looking for attribute values in > the activity's theme, is that where you've specified your values? > > -- Kostya > > 10.01.2011 12:35, Adam Goodchild пишет: > > > > > Hey, > > > Ive been looking into getting Custom Attributes working within an > > application. I have this working up to the point where I am able to > > assign the custom attribute via XML to one of my Views (a Background > > or Image Source for example). > > > What I now want to do is access the Custom Attributes via Code, within > > my Activity. I am not implementing custom Views here. I am just > > wanting to access, within my Activity, the custom attributes that I > > have defined. I will use these to programatically change the look of > > my List View based on certain criteria. > > > Is there a way I can do this? I have the following code, but it does > > not work, returns null each time. The code is just a test to assign a > > background of the splash programatically. > > > �...@override > > public void onCreate(Bundle icicle) { > > super.onCreate( > > > setContentView(R.layout.splash); > > > TypedArray a = > > getApplicationContext().obtainStyledAttributes(R.styleable.MainSplash); > > int i = > > a.getResourceId(R.styleable.MainSplash_splashDrawable, 0); > > } > > > I always get returned '0' when using the above code. Any ideas? > > -- > Kostya Vasilyev -- WiFi Manager + pretty widget > --http://kmansoft.wordpress.com -- 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