Hi,
I'm trying to set a widget's "style" attribute with a reference to a
custom attribute that's been loaded with a real-concrete style.
The Android SDK docs show an explicit example for just setting the
textColor attribute based on a style reference:
<EditText id="text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorSecondary"
android:text="@string/hello_world" />
I'm trying to do this for the entire widget's style, like this....
<Button style="?FoobarButtonStyle"
android:id="@android:id/button1"
android:text="@string/button_cancel"
android:layout_weight="1""/>
When doing this, I get a runtime crash indicating that I have not set
the required elements, but these are set within the style referenced
by "?FoobarButtonStyle"
Is this possible? Anyone tried anything like this? Any help on the
use of the "?" operator and setup of attributes?
BACKGROUND INFO
Here's more info on the strategy that I've ended up taking:
First, I setup a set of attributes which map to all of the styles that
I'm using in the widgets, note that I've set the type of attribute to
"reference," because I think that I'm referencing another resource and
not just string / integer type:
<declare-styleable name="FoobarStyleMap">
<attr name="FoobarSetupWizardStyle" format="reference"/>
<attr name="FoobarSetupWizardStyle_Heading" format="reference"/>
<attr name="FoobarSetupWizardStyle_Heading_Black"
format="reference"/
>
<attr name="FoobarSetupWizardStyle_Heading_Orange"
format="reference"/>
<attr name="FoobarSetupWizardStyle_Body" format="reference"/>
<attr name="FoobarSetupWizardStyle_Body_Black"
format="reference"/>
...
</declare-styleable>
Then, I created an actual style which maps actual style elements to
the attributes:
<style name="Resolution_320x480">
<item name="FoobarSetupWizardStyle">@style/
FoobarSetupWizard_320x480</item>
<item name="FoobarSetupWizardStyle_Heading">@style/
FoobarSetupWizard_320x480.Heading</item>
<item name="FoobarSetupWizardStyle_Heading_Black">@style/
FoobarSetupWizard_320x480.Heading.Black</item>
<item name="FoobarSetupWizardStyle_Heading_Orange">@style/
FoobarSetupWizard_320x480.Heading.Orange</item>
<item name="FoobarSetupWizardStyle_Body">@style/
FoobarSetupWizard_320x480.Body</item>
<item name="FoobarSetupWizardStyle_Body_Black">@style/
FoobarSetupWizard_320x480.Body.Black</item>
<item name="FoobarSetupWizardStyle_Body_White">@style/
FoobarSetupWizard_320x480.Body.White</item>
<item name="FoobarSetupWizardStyle_Body_Orange">@style/
FoobarSetupWizard_320x480.Body.Orange</item>
<item name="FoobarSetupWizardStyle_Fineprint">@style/
FoobarSetupWizard_320x480.Fineprint</item>
....
</style>
--
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