navBarHidden and tabBarHidden
Hi
I am having problems with navBarHidden and tabBarHidden on one of my windows. I have a TabGroup on which I want to hide the nav and tab bar for the first window, trouble is that when I use an EventListener the other windows have nav and tab bar hidden.
Hope that makes sense hehe, below is my code.
Thanks
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// search window
//
var MenuWindow = Titanium.UI.createWindow({
title:'Menu',
navBarHidden: true,
tabBarHidden: true,
//url:'search.js',
backgroundColor:'#fff'
});
var MenuTab = Titanium.UI.createTab({
title:'Menu',
window:MenuWindow
});
var searchButton = Titanium.UI.createButton({
image:'images/search-menu-button.png',
height:47,
top:100,
left:0,
width:320
});
MenuWindow.add(searchButton);
searchButton.addEventListener('click',function(e)
{
var win = Titanium.UI.createWindow({
url:'search.js',
backgroundColor:'#ffffff',
barColor:'#81A61C',
title:'SEARCH',
navBarHidden:false,
tabBarHidden:false
});
win.open(win);
});
//
// search window
//
var SearchWindow = Titanium.UI.createWindow({
title:'Search',
url:'search.js',
backgroundColor:'#fff'
});
var SearchTab = Titanium.UI.createTab({
title:'Search',
window:SearchWindow
});
//
// favorites window
//
var FavoritesWindow = Titanium.UI.createWindow({
title:'Favorites',
backgroundColor:'#fff',
barColor:'#81A61C',
url:'favorites.js'
});
var FavoritesTab = Titanium.UI.createTab({
title:'My Favorites',
window:FavoritesWindow
});
//
// create list window
//
var CreateListWindow = Titanium.UI.createWindow({
title:'My Lists',
url:'lists.js',
barColor:'#81A61C',
backgroundColor:'#fff'
});
var CreateListTab = Titanium.UI.createTab({
title:'My Lists',
window:CreateListWindow
});
//
// settings
//
var SettingsWindow = Titanium.UI.createWindow({
title:'Settings',
barColor:'#81A61C',
backgroundColor:'#fff'
});
var SettingsTab = Titanium.UI.createTab({
title:'Settings',
window:SettingsWindow
});
//
// add tabs
//
tabGroup.addTab(MenuTab);
tabGroup.addTab(SearchTab);
tabGroup.addTab(FavoritesTab);
tabGroup.addTab(CreateListTab);
tabGroup.addTab(SettingsTab);
// open tab group
tabGroup.open();
6 Answers
-
Accepted Answer
Alan
Then you don't need to create a new window at all. Instead, do this:
searchButton.addEventListener('click',function(e) { tabGroup.setActiveTab(1); });
-
Alan
This almost worked OK for me, except for the error win.open(win). I've amended it in this code below, which is tested and runs, along with a couple of modifications to make it work on my system (I didn't have your search.js script or button image etc).
Titanium.UI.setBackgroundColor('#000'); var tabGroup = Titanium.UI.createTabGroup(); var MenuWindow = Titanium.UI.createWindow({ title:'Menu', navBarHidden: true, tabBarHidden: true, //url:'search.js', backgroundColor:'red' }); var MenuTab = Titanium.UI.createTab({ title:'Menu', window:MenuWindow }); var searchButton = Titanium.UI.createButton({ // image:'images/search-menu-button.png', height:47, top:100, left:0, width:320 }); MenuWindow.add(searchButton); searchButton.addEventListener('click',function(e) { var win = Titanium.UI.createWindow({ backgroundColor:'green', barColor:'#81A61C', title:'SEARCH', navBarHidden:false, tabBarHidden:false }); win.open(); }); var SearchWindow = Titanium.UI.createWindow({ title:'Search', // url:'search.js', backgroundColor:'blue' }); var SearchTab = Titanium.UI.createTab({ title:'Search', window:SearchWindow }); var FavoritesWindow = Titanium.UI.createWindow({ title:'Favorites', backgroundColor:'#fff', barColor:'#81A61C', // url:'favorites.js' }); var FavoritesTab = Titanium.UI.createTab({ title:'My Favorites', window:FavoritesWindow }); var CreateListWindow = Titanium.UI.createWindow({ title:'My Lists', // url:'lists.js', barColor:'#81A61C', backgroundColor:'#fff' }); var CreateListTab = Titanium.UI.createTab({ title:'My Lists', window:CreateListWindow }); var SettingsWindow = Titanium.UI.createWindow({ title:'Settings', barColor:'#81A61C', backgroundColor:'#fff' }); var SettingsTab = Titanium.UI.createTab({ title:'Settings', window:SettingsWindow }); tabGroup.addTab(MenuTab); tabGroup.addTab(SearchTab); tabGroup.addTab(FavoritesTab); tabGroup.addTab(CreateListTab); tabGroup.addTab(SettingsTab); tabGroup.open();
-
Thanks but my nav and tab bars are still not showing up on my search page.
Alan
-
@Hal H, hey that worked thanks :-) Just one more question…
Is it possible to hide the Menu window/tab from the nav bar?
Thanks again
Alan
-
Alan
There is a tabgroup method called hide(), but on android you lose control of the window. See ticket #630 for information about this issue.Unfortunately I don't have access to ios, but you could try it using the following code:
searchButton.addEventListener('click',function(e) { tabGroup.setActiveTab(1); tabGroup.hide(); });
Hope this helps
-
Thanks but tabGroup.hide(); cause everything to be hidden after the first screen. Will need to look into this a bit more.
Thanks
Alan