2 buttons with 2 different views - display error when navigating back
I've managed to get two buttons to open up two different views using the code below. However, when I navigate back to the first/main page (using the back button in the top left hand corner) only one of the buttons appears. The button that appears is always the one I clicked. For example, if I click button one, it opens up a new window, but when I navigate back to the main page only button one is displayed (and button two is displayed when I navigate back if I clicked button two). How do I reset the original button view on the main page? Or remove a listener? Or do I have to do something else entirely? Any help appreciated. Thanks. John
var win = Titanium.UI.currentWindow;
var bb2 = Titanium.UI.createButtonBar({
labels:['One', 'Two'],
backgroundColor:'maroon'
});
var flexSpace = Titanium.UI.createButton({
systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});
win.setToolbar([flexSpace,bb2,flexSpace]);
bb2.addEventListener('click', function(e)
{
if (e.index == 0)
{
bb2.labels = ['One'];
win = Titanium.UI.createWindow({
url:'../examples/arthur1.js',
title:'View 1',
backgroundColor:'#fff',
barColor:'#111'
});
}
if (e.index == 1)
{
bb2.labels = ['Two'];
win = Titanium.UI.createWindow({
url:'../examples/arthur2.js',
title:'View 2',
backgroundColor:'#fff',
barColor:'#111'
});
}
Titanium.UI.currentTab.open(win,{animated:true});
});
1 Answer
-
Accepted Answer
Then leave the tittle dont change it. i mean in
1st method :bb2.addEventListener('click', function(e){
if (e.index == 0)
{
//bb2.labels = ['One'];
your code
}if (e.index == 1)
{
bb2.labels = ['Two'];
your code
}2nd method :
you have to add some code for back button i.e.,
backbutton.addEventListener('click', function()
{
bb2.labels = ['One', 'Two'];
}for this you need to create one more back button which should be implemented by you