Created
April 21, 2011 16:01
-
-
Save SteveTrautmanPEI/934847 to your computer and use it in GitHub Desktop.
Titatium mobile tableview out of memory error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Titanium.UI.setBackgroundColor('#000'); | |
| var win1 = Titanium.UI.createWindow({ | |
| backgroundColor:'#fff' | |
| }); | |
| var btn = Ti.UI.createButton({ | |
| color: 'black', | |
| layout:'center', | |
| title: 'Create big table view', | |
| focusable: true | |
| }); | |
| win1.add(btn); | |
| win1.open(); | |
| btn.addEventListener('click', function() { | |
| var newWin = Titanium.UI.createWindow({ | |
| backgroundColor: '#fff', | |
| layout:'vertical' | |
| }); | |
| var back = Ti.UI.createButton({ | |
| color: 'black', | |
| top: 10, | |
| title: 'Back', | |
| focusable: true | |
| }); | |
| back.addEventListener('click', function() {newWin.close();}); | |
| newWin.add(back); | |
| var tv = createBigTableView(); | |
| newWin.add(tv); | |
| newWin.open(); | |
| }); | |
| function createBigTableView() | |
| { | |
| var data = []; | |
| for (i=1; i<=1500; i++) | |
| { | |
| data.push(createCustomTableViewRow('RowsNMore', i)); | |
| } | |
| var tv = Ti.UI.createTableView({ | |
| top:0, bottom:0, left:0, right:0, | |
| separatorColor: "white", | |
| data: data | |
| }); | |
| return tv; | |
| } | |
| // createCustomTableViewRow | |
| // | |
| // create a TableViewRow with two vertically stacked labels, the first label bold, | |
| // the second with a smaller font size and gray | |
| function createCustomTableViewRow(label1text, label2text) | |
| { | |
| var row = Ti.UI.createTableViewRow({ | |
| hasChild: false, | |
| className: "customTVRow" | |
| }); | |
| var vw = Ti.UI.createView({layout: 'vertical'}); | |
| row.add(vw); | |
| var label1 = Ti.UI.createLabel({ | |
| text: label1text, | |
| color: 'black', | |
| font: {fontSize: '9pt', fontWeight: 'bold'}, | |
| left: 10 | |
| }); | |
| vw.add(label1); | |
| var label2 = Ti.UI.createLabel({ | |
| text: label2text, | |
| color: 'gray', | |
| font: {fontSize: '7pt', fontWeight: 'normal'}, | |
| left: 10 | |
| }); | |
| vw.add(label2); | |
| return row; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment