I am programming an App on the iPhone, with Titanium Developer 1.2.2. My app.js simply calls an image (splash screen), then on a click will go to the main win:
Titanium.UI.setBackgroundColor('#000'); var win = Titanium.UI.createWindow({ title: 'CSR', backgroundColor:'#ffffff' }); var imageView = Titanium.UI.createImageView({ image:'images/csrmobile_splash.png', width: 320, height:480 }); imageView.addEventListener('click', function(e) { var main_win = Ti.UI.createWindow({url:"js/main.js"}); main_win.open(); }); win.add(imageView); win.open();That listener works fine. In main.js, I create two tabs (one for guide, one for about us) then set their links:
var tabGroup = Titanium.UI.createTabGroup(); var home_window = Titanium.UI.createWindow({ title: 'Online Course Guide', url: 'home.js' }); var home_tab = Titanium.UI.createTab({ icon:'../images/KS_nav_views.png', title: 'Guide', window:home_window }); var about_win = Titanium.UI.createWindow({ url: 'aboutus.js' }); var about_tab = Titanium.UI.createTab({ icon:'../images/KS_nav_ui.png', title: 'About Us', window:about_win }); tabGroup.addTab(home_tab); tabGroup.addTab(about_tab); tabGroup.setActiveTab(0); tabGroup.open({ transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT });This rightly passes control to tab(0) and displays my table-view page by going to home.js:
var cur_win = Ti.UI.currentWindow; var data = [ { title : 'Option-1', hasChild:true, path : 'option1.js', titleImage : '../images/headico-sm.jpg', leftImage: '../images/leftico.jpg', col : '#007c28' }, { title : 'Option-2', hasChild:true, path : 'option2.js', titleImage : '../images/headico-sm.jpg', leftImage: '../images/leftico.jpg', col : '#007c28' }, { title : 'Option-3', hasChild:true, path : 'option3.js', titleImage : '../images/headico-sm.jpg', leftImage: '../images/leftico.jpg', col : '#007c28' }, { title : 'Option-4', hasChild:true, path : 'option4.js', titleImage : '../images/headico-sm.jpg', leftImage: '../images/leftico.jpg', col : '#007c28' }, { title : 'Option-5', hasChild:true, path : 'option5.js', titleImage : '../images/headico-sm.jpg', leftImage: '../images/leftico.jpg', col : '#007c28' }, { title : 'Option-6', hasChild:true, path : 'option6.js', titleImage : '../images/headico-sm.jpg', leftImage: '../images/leftico.jpg', col : '#007c28' } ]; //Create table for choices and fill with the above data var tableView = Titanium.UI.createTableView ({ data : data }); //When item is clicked on, create a new window and show it tableView.addEventListener('click', function(e) { alert("You clicked?"); if (e.rowData.path) { new_window = Titanium.UI.createWindow({ url : e.rowData.path, title : e.rowData.title, titleImage : e.rowData.titleImage, barColor : data[e.index].col }); Titanium.UI.currentTab.open(new_window,{animated:true}); }; }); cur_win.add(tableView); cur_win.open();The view displays properly, but tabs or tabled items are not clickable. When I put the alert trap in the listener (as you see) I never get that alert, so it means the listener isn't firing some how.
Can someone please show me the error of my ways?
Thanks!
1 Answer
Accepted Answer
I believe you need to add the tabGroup to the window
// main.js var cur_win = Ti.UI.currentWindow; var tabGroup = Titanium.UI.createTabGroup(); cur_win.add(tabGroup);
Your Answer
Think you can help? Login to answer this question!