Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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();
— asked November 24th 2010 by Alan Tucker
  • iphone
0 Comments

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);
    });
    
    — answered November 24th 2010 by Paul Dowsett
    permalink
    1 Comment
    • Alan

      It is not clear on which window you want the tab bar hidden. When you run my code, what colour is the window where you want to see this behaviour?

      — commented November 24th 2010 by Paul Dowsett
  • 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();
    
    — answered November 24th 2010 by Paul Dowsett
    permalink
    0 Comments
  • Thanks but my nav and tab bars are still not showing up on my search page.

    Alan

    — answered November 24th 2010 by Alan Tucker
    permalink
    1 Comment
    • Hi Alan, I am facing the Same problem as you tackled now !
      i am not able to show the tabBar again after hiding Once. can you tell me the Solution. its like urgent.

      var win = Ti.UI.createWindow({
      title:'Take Photo',
      url:'Take_Photo.js',
      barColor:'#111',
      tabBarHidden:'false',
      navBarHidden:'false',
      param:Ti.App.globalArray[NewWin.param].img_path,
      paramEdit:'true',
      ind:NewWin.param
      });

      Ti.UI.currentTab.open(win); 
      //win.open();
      Ti.App.myCustomTabBar.show();
      

      i am using a Custom TabBar.Which i can hide and Show during hidding the tabbar.That working fine.But tabBarHidden:false is not working at all.

      — commented December 7th 2011 by Suresh Sharma
  • @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

    — answered November 24th 2010 by Alan Tucker
    permalink
    0 Comments
  • 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

    — answered November 24th 2010 by Paul Dowsett
    permalink
    0 Comments
  • Thanks but tabGroup.hide(); cause everything to be hidden after the first screen. Will need to look into this a bit more.

    Thanks

    Alan

    — answered November 24th 2010 by Alan Tucker
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.