[AC-1009] ListView does not allow attributedString to be set on label
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-03-12T05:23:13.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Alloy |
Labels | attributedString, listview |
Reporter | Jerod Fritz |
Assignee | Ritu Agrawal |
Created | 2014-03-03T19:03:41.000+0000 |
Updated | 2016-03-08T07:37:20.000+0000 |
Description
*Overview*
I would like to use the attributedString property to apply styling to a specific range of text inside a label but there is a context problem
*Steps to Reproduce*
Use the code below to create a ListView and apply a TiUIiOSAttributedString to the attributedString property of the label via the binded id
...
<ListView id="listView" defaultItemTemplate="result">
<Templates>
<ItemTemplate name="result">
<View id="row">
<Label bindId="snippet" id="snippet" />
</View>
</ItemTemplate>
</Templates>
<ListSection id="section"></ListSection>
</ListView>
...
var snippet = "Test string";
var formatter = Titanium.UI.iOS.createAttributedString({
text : snippet,
attributes : [{
type : Titanium.UI.iOS.ATTRIBUTE_BACKGROUND_COLOR,
value : 'yellow',
range : [0, 4]
}]
});
var item = {
snippet : {
text : snippet,
attributedString : formatter
},
properties : {
height : Ti.UI.SIZE,
accessoryType : 1,
itemId : 0,
},
};
$.section.appendItems([item]);
*Observed Behavior*
The attributed string is ignored and a WARN is generated in the console that reads
[WARN] : Creating [object TiUIiOSAttributedString] in a different context than the calling function.
*Expected Behavior*
The example allows me to style the listitem's label showing "Test string" with "Test" atop a yellow background.
Can you please attach the runnable code so that we can try to reproduce the issue?
Ritu, In creating the fully runnable code I was unable to reproduce so my context issue must be something I'm doing. My test code uses the attributedString fine. Apologies for not doing that first. Please close this ticket as invalid. Thanks, Jerod