Problem description
Trying to update an image inside a TableViewRow works only a couple of time; after that, the image properties can be changed (e.g. right), but not the image itself.
Steps to reproduce
Use the following code:
Ti.UI.backgroundColor = '#e3e8ee';
var win = Ti.UI.createWindow();
var table = Ti.UI.createTableView();
var rows = [];
for (var i = 1; i <= 50; i++) {
var row = Ti.UI.createTableViewRow({
height : '40dp'
});
var label = Ti.UI.createLabel({
height : Ti.UI.SIZE,
left : '5dp',
text : 'Row ' + i,
top : '5dp',
width : Ti.UI.SIZE
});
row.text = label;
row.add(row.text);
var image = Ti.UI.createImageView({
height : '28dp',
image : '/images/radiobutton_off.png',
right : '0dp',
top : '5dp',
width : '34dp'
});
row.image = image;
row.add(row.image);
rows.push(row);
}
table.setData(rows);
win.add(table);
win.open();
setActive(0);
function setActive (_index) {
for (var i = 0; i < table.data[0].rows.length; i++) {
if (i === _index) {
table.data[0].rows[i].text.text = "Row " + i + " ON";
table.data[0].rows[i].image.image = '/images/radiobutton_on.png';
table.data[0].rows[i].image.right = '50dp';
}
else {
table.data[0].rows[i].text.text = "Row " + i;
table.data[0].rows[i].image.image = '/images/radiobutton_off.png';
table.data[0].rows[i].image.right = '0dp';
}
}
}
table.addEventListener('click', function (e) {
setActive(e.index);
});
Running the code on Android, you can notice how automatically the first row changes: the label text shows "ON", the image is moved 30dp from the right and the image itself changes to the active button.
Clicking a row, the process works again on that row.
Click the second time and everything changes, but the image.
Note
I tried SDK from 2.1.3 to 3.0.0, same behavior. I also tried adding a className to the rows (both same class for all the rows, or a different one per row), nothing changes.
The workaround involves using 2 images instead of one, and showing/hiding them.
PR https://github.com/appcelerator/titanium_mobile/pull/3689
Image is getting updated for every click. Environment used for verification - Titanium SDK: 3.1.0.v20130114171802 Titanium Studio:3.0.1.201212181159 Device: Samsung GALAXY Note (2.3.6)
Reopening to edit fixVersion
Reopening to update labels
the issue still exists in 3.5.0
I'm still having this issue in 4.0.0.GA