Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 3rd, 2012  |  syntax: None  |  size: 2.39 KB  |  hits: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var tabGroup = Titanium.UI.createTabGroup();
  2. var win1 = Titanium.UI.createWindow({ title:'Tab 1' });
  3. var tab1 = Titanium.UI.createTab({  
  4.     icon:   'KS_nav_views.png',
  5.     title:  'Tab 1',
  6.     window: win1
  7. });
  8.  
  9. var index = 0;
  10. var data = [];
  11.  
  12. //create an initial section with four rows
  13. data[index] = Ti.UI.createTableViewSection({
  14.    headerTitle: "This is the first section"
  15. });
  16.  
  17. for (i = 0; i < 4; i++) {      
  18.    var rowLabel = Ti.UI.createLabel({
  19.       text:    "This is row " + i,
  20.       height:  'auto',
  21.       width:   270,
  22.       left:    10,
  23.       right:   0,
  24.       top:     10,
  25.       bottom:  10,
  26.       font: {  fontSize: 14 }
  27.    });
  28.    
  29.    var sectionRow = Ti.UI.createTableViewRow({
  30.       height: 'auto'
  31.    });
  32.    sectionRow.add(rowLabel);
  33.    data[index].add(sectionRow);
  34. }
  35. index++;
  36.  
  37. //create a second section, with no header and just a large label
  38. data[index] = Ti.UI.createTableViewSection({
  39.    headerTitle: ""
  40. });
  41.  
  42. var row = Ti.UI.createTableViewRow({
  43.    height:         'auto',
  44.    selectionStyle: 0
  45. });
  46.  
  47. var label = Ti.UI.createLabel({
  48.    text: "label start\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nlabel end",
  49.    height:  'auto',
  50.    width:   270,
  51.    left:    10,
  52.    right:   0,
  53.    top:     10,
  54.    bottom:  10,
  55.    font: {  fontSize: 14 }
  56. });
  57.  
  58. row.add(label);
  59. data[index].add(row);
  60. index++;
  61.  
  62. //create a third and final section with four rows
  63. data[index] = Ti.UI.createTableViewSection({
  64.    headerTitle: "This is the third section"
  65. });
  66.  
  67. for (var j = 0; j < 4; j++) {      
  68.    var rowLabel = Ti.UI.createLabel({
  69.       text:    "",
  70.       height:  'auto',
  71.       width:   270,
  72.       left:    10,
  73.       right:   0,
  74.       top:     10,
  75.       bottom:  10,
  76.       font: {  fontSize: 14 }
  77.    });
  78.    
  79.    var rightButton = Ti.UI.createButton({
  80.       style:   Ti.UI.iPhone.SystemButton.DISCLOSURE
  81.    });
  82.    
  83.    var sectionRow = Ti.UI.createTableViewRow({
  84.       height: 'auto'
  85.       //rightImage: 'some_image.png'
  86.    });
  87.    sectionRow.add(rowLabel);
  88.    sectionRow.add(rightButton);
  89.    data[index].add(sectionRow);
  90. }
  91. index++;
  92.  
  93. //add it all to the table
  94. var tableview = Titanium.UI.createTableView({
  95.    data:          data,
  96.    style:         Titanium.UI.iPhone.TableViewStyle.GROUPED,
  97.    minRowHeight:  40,
  98.    top:           0
  99. });
  100.  
  101. //add the tableview to the window, then the window to the tabGroup
  102. win1.add(tableview);
  103. tabGroup.addTab(tab1);
  104. tabGroup.open();