Titanium Community Questions & Answer Archive

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

imageview or button link

Hi

Slowly getting the hang of titanium but cant seem to find an answer for this:
I have a window with four images that I want the user to click on one of the images to go to another view. The Window is not in a tab group just images to navigate between views. I've tried a few event listener options but in the simulator the image (coded as either as a button or just plain imageview) when selected does nothing? any ideas?

— asked October 10th 2010 by Thomas Wilson
  • button
  • imageview
  • url
0 Comments

3 Answers

  • Something like this should work:

    var win = Ti.UI.currentWindow;
    var imageViewButton = Ti.UI.createImageView({
        top:10,
        width:20,
        height:20,
        image:'some_image.png'
    });
    win.add(imageViewButton);
    
    imageViewButton.addEventListener('click',function(){
    
       Ti.API.info('you clicked the view! do something now...');
    
    });
    
    — answered October 10th 2010 by Kosso
    permalink
    1 Comment
    • right so how to call another .js file using a button there isnt such a thing as url:aa.js thin on the button api.

      how can i navigate using a button?

      — commented January 20th 2011 by Fatos S
  • HI Kosso

    Thats fine for creating an alert when clicked but I want it to go to a new view called for example "new.js", its the url bit I need. thanks.

    — answered October 10th 2010 by Thomas Wilson
    permalink
    0 Comments
  • heres what I have so far, there are 4 images, but you get the idea:

    Titanium.UI.setBackgroundColor('#000000');

    // create root window
    var rootWin = Titanium.UI.createWindow({
    title:'Title here'
    });
    var aseriesbutt = Ti.UI.createImageView({
    title:"A Series",
    image:'buttons/ui/a-button.png',
    width:160,
    height:240,
    left:0,
    right:160,
    top:0
    });

    aseriesbutt.addEventListener('click',function(e){
    Ti.UI.createWindow({
    url:'a1.js',
    backButtonTitle:'back',
    title:'A1'
    });
    });

    rootWin.add(aseriesbutt);
    rootWin.open();

    — answered October 10th 2010 by Thomas Wilson
    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.