I have a template defined in Alloy XML like so:
<ItemTemplate name="codexTemplate" class='codexTemplateStyle'> <View layout='vertical'> <Label bindId="codexTitle" class="codexTitleStyle"></Label> <View class="codexImageDescriptionViewStyle"> <ImageView bindId="codexImage" class="codexImageStyle"></ImageView> <Label bindId="codexDescription" class="codexDescriptionStyle"></Label> </View> </View> </ItemTemplate>I would like to duplicate this template in code to apply a new class to the ImageView. Similar to the example in the Titanium ListView sample docs.
var redTemplate = JSON.parse(JSON.stringify(plainTemplate)); // Change the text color to red redTemplate.childTemplates[1].properties.color = 'red'; redTemplate.childTemplates[2].properties.color = 'red';I would like to change the class to:
class="codexStoreImageStyle"However, when the view loads, I have tried getting access to the templates Dictionary from the ListView but it's empty.
Is it possible to define some inheritance structure or achieve what I'm looking for without defining another ItemTemplate with a different name and applying that to the ListDataItem?
I have a number of cases in my App where this would be very useful. I really don't want to define multiple copies of the same template in the XML file with only class changes for specific items if I can help it.
Thank you!