Titanium Community Questions & Answer Archive

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

Trying to link to URLs from a createButtonBar

Hello
I am trying to create links from buttons in a "createButtonBar" to different views . . . I am stuck.

here is code:

//
// TOOLBAR
// 
var bb2 = Titanium.UI.createButtonBar({
    labels:['Current Temps', 'Doppler', 'Satellite'],
    backgroundColor:'#333333',
    BarColor:'#000000',
    index:0
});
var flexSpace = Titanium.UI.createButton({
    systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});

win.setToolbar([flexSpace,bb2,flexSpace]);

bb2.addEventListener('click',function(e) 
{
    // handle tableview click events
    var idx = e.index;
    switch(idx)
    {
        case 0:Titanium.UI.createView({url:'Current.js',})
        case 1:Titanium.UI.createView({url:'satellite.js',})
        case 2:Titanium.UI.createView({url:'doppler.js',})

    }       
});

Thanks

b2e

— asked March 14th 2010 by Jeff Webb
  • addeventlistener
  • createbuttonbar
0 Comments

3 Answers

  • you are just creating views. what do you want to do with them? the code above just creates them but does not do anything with them.

    — answered March 15th 2010 by Nolan Wright
    permalink
    0 Comments
  • Nolan
    Thanks for your help . . . I am looking into buying "Titanium Professional Support" for the year.

    I am trying to click on a buttonbar button and refresh the view with another view . . . in this case another image view . . . below is code that I am currently working on . . .


    var win = Titanium.UI.currentWindow

    Titanium.UI.currentWindow.setBarColor('#000');

    var imageView = Titanium.UI.createImageView({
    url:'http://www.wusa9.com/weather/currents/7day.jpg',
    top:5,
    width:420,
    height:236
    });

    win.add(imageView);

    var l = Titanium.UI.createLabel({
    text:'WUSA9 7 Day Forecast',
    bottom:30,
    color:'#999',
    height:20,
    width:300,
    textAlign:'center'
    });
    win.add(l);

    //
    // TOOLBAR
    //
    var bb2 = Titanium.UI.createButtonBar({
    labels:['Current Temps', 'Doppler', 'Satellite'],
    backgroundColor:'#333333',
    BarColor:'#000000',
    index:0
    });
    var flexSpace = Titanium.UI.createButton({
    systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
    });

    win.setToolbar([flexSpace,bb2,flexSpace]);

    var state = 0;
    bb2.addEventListener('click', function(e)
    {
    var idx = e.index;
    switch(idx)
    {
    case 0:
    {
    Titanium.UI.createView({url:'Current.js'})
    Titanium.UI.currentTab.open(win,{animated:true})
    }

        case 1:
        {
            Titanium.UI.createView({url:'doppler.js'})
            Titanium.UI.currentTab.open(win,{animated:true})
        }
    
        case 2:
        {
            Titanium.UI.createView({url:'satellight.js'})
            Titanium.UI.currentTab.open(win,{animated:true})
        }
    
    
    }
    

    });

    Thanks in advance. I am hoping to have funds for "Titanium Professional" soon . . .

    b2e

    — answered March 15th 2010 by Jeff Webb
    permalink
    0 Comments
  • Nolan
    Thanks for your help . . . I am looking into buying "Titanium Professional Support" for the year.

    I am trying to click on a buttonbar button and refresh the view with another view . . . in this case another image view . . . below is code that I am currently working on . . .


    var win = Titanium.UI.currentWindow

    Titanium.UI.currentWindow.setBarColor('#000');

    var imageView = Titanium.UI.createImageView({
    url:'http://www.wusa9.com/weather/currents/7day.jpg',
    top:5,
    width:420,
    height:236
    });

    win.add(imageView);

    var l = Titanium.UI.createLabel({
    text:'WUSA9 7 Day Forecast',
    bottom:30,
    color:'#999',
    height:20,
    width:300,
    textAlign:'center'
    });
    win.add(l);

    //
    // TOOLBAR
    //
    var bb2 = Titanium.UI.createButtonBar({
    labels:['Current Temps', 'Doppler', 'Satellite'],
    backgroundColor:'#333333',
    BarColor:'#000000',
    index:0
    });
    var flexSpace = Titanium.UI.createButton({
    systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
    });

    win.setToolbar([flexSpace,bb2,flexSpace]);

    var state = 0;
    bb2.addEventListener('click', function(e)
    {
    var idx = e.index;
    switch(idx)
    {
    case 0:
    {
    Titanium.UI.createView({url:'Current.js'})
    Titanium.UI.currentTab.open(win,{animated:true})
    }

        case 1:
        {
            Titanium.UI.createView({url:'doppler.js'})
            Titanium.UI.currentTab.open(win,{animated:true})
        }
    
        case 2:
        {
            Titanium.UI.createView({url:'satellight.js'})
            Titanium.UI.currentTab.open(win,{animated:true})
        }
    
    
    }
    

    });

    Thanks in advance. I am hoping to have funds for "Titanium Professional" soon . . .

    b2e

    — answered March 15th 2010 by Jeff Webb
    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.