Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26627] Android: While updating listview, lable having attribute string goes disappear 7.5.0.GA

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionDuplicate
Resolution Date2019-03-26T17:42:14.000+0000
Affected Version/sRelease 7.5.1
Fix Version/sRelease 8.0.0
Componentsn/a
Labelsandroid, listView
ReporterJebun Naher
AssigneeAlan Hutton
Created2018-12-04T12:23:18.000+0000
Updated2019-03-26T17:42:14.000+0000

Description

*Issue Overview:* Issue is while updating listview, lable having attribute string goes disappear (Refer to the attached screenshot). This doesn't happen on ti sdk 7.4.0.GA. *Steps to reproduce:* 1. Run the test code using sdk 7.5.0.GA 2. Click text "Manzana" 3. Observe that the attributed string "Have you tried hyperloop1 yet" goes disappear. Now, run the test code using 7.4.0.GA and follow the steps again. Observe that, on 7.4.0.GA, the attributed string does not disappear.
var win = Ti.UI.createWindow({
	backgroundColor : 'white'
});
var text = "Have you tried hyperloop1 yet?";
// Create a custom template that displays an image on the left,
// then a title next to it with a subtitle below it.
var myTemplate = {
	childTemplates : [{// Image justified left
		type : 'Ti.UI.ImageView', // Use an image view for the image
		bindId : 'pic', // Maps to a custom pic property of the item data
		properties : {// Sets the image view  properties
			width : '50dp',
			height : '50dp',
			left : 0
		}
	}, {// Title
		type : 'Ti.UI.Label', // Use a label for the title
		bindId : 'info', // Maps to a custom info property of the item data
		properties : {// Sets the label properties
			color : 'black',
			font : {
				fontFamily : 'Arial',
				fontSize : '20dp',
				fontWeight : 'bold'
			},
			left : '60dp',
			top : 0,
			attributedString : Ti.UI.createAttributedString({
				text : text,
				attributes : [{
					type : Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,
					value : Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE, // Ignored by Android only displays a single line
					range : [text.indexOf('hyperloop1'), ('hyperloop1').length]
				}]
			})
		}
	}, {// Subtitle
		type : 'Ti.UI.Label', // Use a label for the subtitle
		bindId : 'es_info', // Maps to a custom es_info property of the item data
		properties : {// Sets the label properties
			color : 'gray',
			font : {
				fontFamily : 'Arial',
				fontSize : '14dp'
			},
			left : '60dp',
			top : '25dp',
		}
	}]
};

var listView = Ti.UI.createListView({
	// Maps myTemplate dictionary to 'template' string
	templates : {
		'template' : myTemplate
	},
	// Use 'template', that is, the myTemplate dict created earlier
	// for all items as long as the template property is not defined for an item.
	defaultItemTemplate : 'template'
});

listView.addEventListener('itemclick', function(e) {

	var item = e.section.getItemAt(e.itemIndex);
	item.es_info.text = "text changed";	
	listView.sections[0].updateItemAt(e.itemIndex, item);
	
	//
	//
	//
	
});

var sections = [];

var fruitSection = Ti.UI.createListSection({
	headerTitle : 'Fruits / Frutas'
});

var fruitDataSet = [
// the text property of info maps to the text property of the title label
// the text property of es_info maps to text property of the subtitle label
// the image property of pic maps to the image property of the image view
{
	/*info : {
	 //text : 'Apple'
	 attributedString : Ti.UI.createAttributedString({
	 text:  text,
	 attributes: [
	 {
	 type: Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,
	 value: Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE, // Ignored by Android only displays a single line
	 range: [text.indexOf('hyperloop'), ('hyperloop').length]
	 }
	 ]
	 }),
	 },*/
	es_info : {
		text : 'Manzana'
	},
	pic : {
		image : 'apple.png'
	}
}];

fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);
listView.setSections(sections);
win.add(listView);
win.open(); 

Attachments

FileDateSize
Screenshot_20181204_162105.jpg2018-12-04T12:22:48.000+000048902
Screenshot_20181204_162109.jpg2018-12-04T12:22:56.000+000032976

Comments

  1. Andrea Vitale 2019-01-24

    Same here!! :-(
  2. Michael Gangolf 2019-01-24

    can you check it with 7.5.1.RC? https://github.com/appcelerator/titanium_mobile/pull/10611 was merged there and other parts are fixed in Listviews
  3. Andrea Vitale 2019-01-24

    Already checked it. I'm currently using 7.5.1.v20190115054254 SDK.
  4. Alan Hutton 2019-03-26

JSON Source