[TIMOB-9905] Android: Tableview not updated when a new view is added to a tableviewrow
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-06-19T11:13:26.000+0000 |
Affected Version/s | Release 2.1.0 |
Fix Version/s | Sprint 2012-16 API, Release 3.0.0 |
Components | Android |
Labels | api, module_tableview, qe-testadded |
Reporter | Anirudh Nagesh |
Assignee | Hieu Pham |
Created | 2012-07-06T15:46:32.000+0000 |
Updated | 2013-06-19T11:13:26.000+0000 |
Description
Tableview does not get updated when a new view ( label, text area) is added to the tableviewrow. Works fine on iOS.
1. Run the code below in app.js
var _window = Ti.UI.createWindow({
backgroundColor:'#fff'
});
row = Ti.UI.createTableViewRow({
width: 300,
height: 40
});
nameLabel = Titanium.UI.createLabel({
text: 'Title',
left: 10
});
row.add(nameLabel);
tableView = Ti.UI.createTableView({
backgroundColor: 'white',
top: 0, width: 300,
height: Ti.UI.SIZE,
data: [row]
});
addButton = Ti.UI.createButton({
title: 'Add Label',
width: 200, height: 100
});
addButton.addEventListener('click', function() {
valueLabel1 = Ti.UI.createLabel({
text: 'New Label',
right: 15,
width: 'auto'
});
row.add(valueLabel1);
Ti.API.info('self contents....'+row.children[1].text);
});
_window.add(tableView);
_window.add(addButton);
_window.open();
On iOS, new label gets added to the tableview row.
On Android, label gets added to the tableview row ( info statement seen in ddms) but view not updated.
Workaround: Use setData() to reset the tableview rows. ( works fine on both iOS and Android)
There are similar situations where update of table view doesn't trigger re-layout cycle automatically (like adding table view sections after table view is rendered), therefore developer has to do it programmatically (via setting same data: table.setData(table.data) ). It would be nice if developer wouldn't need to trigger re-layout programmatically.
Client has come back and asked for this to take high priority as they are looking to submit their app to the App Store by 8/10. If you can come up with a work-around, we are also open to that as a solution.
Fixed by https://github.com/appcelerator/titanium_mobile/pull/2691
Verified fixed with mobile sdk-2.2.0.v20120810080115 Titanium Studio, build: 2.1.1.201207271312 Galaxy S III Android version 4.0.4
Opened just to update the label
Label updated and verified Tested on: Device: Google Nexus Android Version 4.0.4, SDK:3.1.2.v20130617140100 Appcelerator Studio: 3.1.1.201306131423 OS: OSX 10.8 acs:1.0.3 alloy:1.1.3-cr npm:1.2.14 titanium:3.1.1-cr titanium-code-processor:1.0.1-cr5