Programmatically update TabBar Labels in Corona SDK

Hey
If I create a tabBar like below and all the settings are stored in a separate lua-module which I prefer to to but now I need to update the textlabels in the tabbar from within code and how to I get a hold on each tabbar buttons label text?

[lua]local tabButtons = {
{ label=“tab1”, up=app.tabBar1Up, down=app.tabBar1Down, width = app.tabBar1Width, height = app.tabBar1Height, onPress=onFirstView, selected=app.tabBar1Selected },
{ label=“tab2”, up=app.tabBar2Up, down=app.tabBar2Down, width = app.tabBar2Width, height = app.tabBar2Height, onPress=onSecondView, selected=app.tabBar2Selected },
{ label=“tab3”, up=app.tabBar3Up, down=app.tabBar3Down, width = app.tabBar3Width, height = app.tabBar3Height, onPress=onThirdView, selected=app.tabBar3Selected },
{ label=“tab4”, up=app.tabBar4Up, down=app.tabBar4Down, width = app.tabBar4Width, height = app.tabBar4Height, onPress=onFourthView, selected=app.tabBar4Selected },
}

tabBar = widget.newTabBar{
top = display.contentHeight - 50, – 50 is default height for tabBar widget
buttons = tabButtons
}[/lua]

Any help would be appreciated? [import]uid: 22737 topic_id: 21119 reply_id: 321119[/import]

you could define it like this

local tabButtons = {  
 { label="tab1", up=app.tabBar1Up, down=app.tabBar1Down, width = app.tabBar1Width, height = app.tabBar1Height, onPress=onFirstView, selected=app.tabBar1Selected },  
 { label="tab2", up=app.tabBar2Up, down=app.tabBar2Down, width = app.tabBar2Width, height = app.tabBar2Height, onPress=onSecondView, selected=app.tabBar2Selected },  
 { label="tab3", up=app.tabBar3Up, down=app.tabBar3Down, width = app.tabBar3Width, height = app.tabBar3Height, onPress=onThirdView, selected=app.tabBar3Selected },  
 { label="tab4", up=app.tabBar4Up, down=app.tabBar4Down, width = app.tabBar4Width, height = app.tabBar4Height, onPress=onFourthView, selected=app.tabBar4Selected },  
}  
   
\_G.tabBar = widget.newTabBar{  
 top = display.contentHeight - 50, -- 50 is default height for tabBar widget  
 buttons = tabButtons  
}  
  

then access them like this :

[code]
local theTabBar = _G.tabBar

theTabBar.buttons[1].label = “Hello!” [import]uid: 84637 topic_id: 21119 reply_id: 83643[/import]

In some strange way the text does not change when I try your sample. It seem perfect in all ways but the text does not get updated. [import]uid: 22737 topic_id: 21119 reply_id: 83735[/import]

Sorry I forgot some stuff, this is how I am handling it in my app (there is probably a better way)

[code]

–Create your tab bar like so (in main.lua preferably)

_G.tabButtons = {
{ label=“tab1”, up=app.tabBar1Up, down=app.tabBar1Down, width = app.tabBar1Width, height = app.tabBar1Height, onPress=onFirstView, selected=app.tabBar1Selected },
{ label=“tab2”, up=app.tabBar2Up, down=app.tabBar2Down, width = app.tabBar2Width, height = app.tabBar2Height, onPress=onSecondView, selected=app.tabBar2Selected },
{ label=“tab3”, up=app.tabBar3Up, down=app.tabBar3Down, width = app.tabBar3Width, height = app.tabBar3Height, onPress=onThirdView, selected=app.tabBar3Selected },
{ label=“tab4”, up=app.tabBar4Up, down=app.tabBar4Down, width = app.tabBar4Width, height = app.tabBar4Height, onPress=onFourthView, selected=app.tabBar4Selected },
}

_G.tabBar = widget.newTabBar{
top = display.contentHeight - 50, – 50 is default height for tabBar widget
buttons = _G.tabButtons
}

–Put below code where you want to change the label

–Refresh it (by removing and reinitializing)
display.remove(_G.tabBar)

–Change label
_G.tabButtons[1].label = “Hello”

_G.tabBar = widget.newTabBar{
top = display.contentHeight - 50, – 50 is default height for tabBar widget
buttons = _G.tabButtons
}

[import]uid: 84637 topic_id: 21119 reply_id: 83757[/import]

This is a little dated thread but I was wondering if a better way has been discovered in the meanwhile. I am having to refresh my tabBar to cope with orientation changes. I tried this method and it seems to work well but if there is a better way… Thanks much in advance. 

This is a little dated thread but I was wondering if a better way has been discovered in the meanwhile. I am having to refresh my tabBar to cope with orientation changes. I tried this method and it seems to work well but if there is a better way… Thanks much in advance.