Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Titanium.include('data.json');
- var data = [];
- // loop through data and add to list
- for (var i = 0; i < myData.length; i++)
- {
- data.push({title:myData[i].ticker,hasChild:true});
- }
- ////////////////////////////////////////////////////
- var search = Titanium.UI.createSearchBar({barColor:'#000',showCancel:true});
- // create table view
- var StockTableView = Titanium.UI.createTableView({data:data});
- ////////////////////////////////////////////////////
- Titanium.UI.currentWindow.add(StockTableView);
- StockTableView.search = search;
- // When a table is clicked
- StockTableView.addEventListener('click', function(e)
- {
- //create a window
- var subwin = Titanium.UI.createWindow({
- backgroundColor:'#ffffff',
- barColor:'#333333',
- //with the same title as the article name from the table view
- title:e.rowData.title
- });
- //loop to capture all table entries
- for (var i = 0; i < myData.length; i++)
- {
- if (myData[i].ticker == subwin.title)
- {
- desc = myData[i].name;
- }
- }
- //open the article window under the current tab
- Titanium.UI.currentTab.open(subwin,{animated:true});
- //Create a scrollView so article scrolls
- var scrollable = Titanium.UI.createScrollView({
- contentWidth:'auto',
- contentHeight: 'auto',
- showHorizontalScrollIndicator: 'true',
- showVerticalScrollIndicator: 'true'
- });
- //Create a Label to hold the article
- var label = Titanium.UI.createLabel({
- text:desc,
- left:5,
- top:5,
- height:'auto'
- });
- //place the article on the scrollview
- scrollable.add(label);
- //and the scrollview on the window
- subwin.add(scrollable);
- });
Add Comment
Please, Sign In to add comment