Guest User

Untitled

a guest
May 28th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1.  
  2. Ti.UI.setBackgroundColor('#000');
  3.  
  4. var db = Ti.Database.install("cpi.sqlite", "cpi");
  5. var result = db.execute("SELECT year FROM cpi_index");
  6. var years = [];
  7.  
  8. var counter = 0;
  9. do
  10. {
  11. years[counter] = Ti.UI.createTableViewRow({title: result.field("year").toString()});
  12. counter++;
  13. }
  14. while (result.next());
  15.  
  16. var win1 = Ti.UI.createWindow
  17. ({
  18. title:'Tab 1',
  19. backgroundColor:'#fff'
  20. });
  21.  
  22. result.close();
  23.  
  24. var tablesView = Ti.UI.createView
  25. ({
  26.  
  27. left: 10,
  28. width: 400,
  29. height: 400
  30. });
  31.  
  32. var tablePastLabel = Ti.UI.createLabel
  33. ({
  34. text: "Select past date",
  35.  
  36. left: 10,
  37. bottom: 300
  38. });
  39.  
  40. var testLabel = Ti.UI.createLabel
  41. ({
  42. text: "",
  43.  
  44. left: 150,
  45. bottom: 350
  46. });
  47.  
  48. var tableFutureLabel = Ti.UI.createLabel
  49. ({
  50. text: "Select future date",
  51.  
  52. left: 200,
  53. bottom: 300
  54. });
  55.  
  56. var tablePast = Ti.UI.createTableView
  57. ({
  58. allowsSelection: true,
  59. data: years,
  60. style: Ti.UI.iPhone.TableViewStyle.GROUPED,
  61. separatorColor: "red",
  62.  
  63. left: 10,
  64. width: 100,
  65. height: 250,
  66. borderColor: "blue"
  67. });
  68.  
  69. var tableFuture = Ti.UI.createTableView
  70. ({
  71. allowsSelection: true,
  72. data: years,
  73. style: Ti.UI.iPhone.TableViewStyle.GROUPED,
  74. separatorColor: "red",
  75.  
  76. left: 200,
  77. width: 100,
  78. height: 250,
  79. borderColor: "blue"
  80. });
  81.  
  82. tablesView.add(testLabel);
  83. tablesView.add(tableFutureLabel);
  84. tablesView.add(tablePastLabel);
  85. tablesView.add(tablePast);
  86. tablesView.add(tableFuture);
  87.  
  88. /*******************************************************************/
  89. tablePast.addEventListener('click', function(e)
  90. {
  91. tablePastLabel.text = "TEST";
  92. });
  93. /******************************************************************/
  94.  
  95. win1.add(tablesView);
  96. win1.open();
Add Comment
Please, Sign In to add comment