Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1009] ListView does not allow attributedString to be set on label

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-03-12T05:23:13.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy
LabelsattributedString, listview
ReporterJerod Fritz
AssigneeRitu Agrawal
Created2014-03-03T19:03:41.000+0000
Updated2016-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.

Comments

  1. Ritu Agrawal 2014-03-11

    Can you please attach the runnable code so that we can try to reproduce the issue?
  2. Jerod Fritz 2014-03-11

    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

JSON Source