Guest User

Untitled

a guest
Jan 12th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. Titanium.include('data.json');
  2.  
  3. var data = [];
  4.  
  5. // loop through data and add to list
  6. for (var i = 0; i < myData.length; i++)
  7. {
  8. data.push({title:myData[i].ticker,hasChild:true});
  9. }
  10. ////////////////////////////////////////////////////
  11. var search = Titanium.UI.createSearchBar({barColor:'#000',showCancel:true});
  12. // create table view
  13. var StockTableView = Titanium.UI.createTableView({data:data});
  14. ////////////////////////////////////////////////////
  15. Titanium.UI.currentWindow.add(StockTableView);
  16. StockTableView.search = search;
  17.  
  18. // When a table is clicked
  19. StockTableView.addEventListener('click', function(e)
  20. {
  21. //create a window
  22. var subwin = Titanium.UI.createWindow({
  23. backgroundColor:'#ffffff',
  24. barColor:'#333333',
  25. //with the same title as the article name from the table view
  26. title:e.rowData.title
  27. });
  28. //loop to capture all table entries
  29. for (var i = 0; i < myData.length; i++)
  30. {
  31. if (myData[i].ticker == subwin.title)
  32. {
  33. desc = myData[i].name;
  34. }
  35. }
  36.  
  37. //open the article window under the current tab
  38. Titanium.UI.currentTab.open(subwin,{animated:true});
  39.  
  40. //Create a scrollView so article scrolls
  41. var scrollable = Titanium.UI.createScrollView({
  42. contentWidth:'auto',
  43. contentHeight: 'auto',
  44. showHorizontalScrollIndicator: 'true',
  45. showVerticalScrollIndicator: 'true'
  46. });
  47.  
  48. //Create a Label to hold the article
  49. var label = Titanium.UI.createLabel({
  50. text:desc,
  51. left:5,
  52. top:5,
  53. height:'auto'
  54. });
  55.  
  56. //place the article on the scrollview
  57. scrollable.add(label);
  58. //and the scrollview on the window
  59. subwin.add(scrollable);
  60. });
Add Comment
Please, Sign In to add comment