Titanium Community Questions & Answer Archive

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

click image in table row and update other images in same table row

Hello all,
I need to be able to click each checkbox image and either check or uncheck it which i can do just fine…the prob is that if i 'check' a checkbox i need to 'uncheck' the previously checked box - but i don't know how to access the other images or their views.

How I'm adding images

for(s=0;s<=4;s++){
  var projStatusView = 'textLabel'+i;
  projStatusView = Ti.UI.createView({ //stuff });

  var projStatusImgLabel = 'textLabel'+i;
  projStatusImgLabel = Ti.UI.createLabel({ //stuff });

  var cb = [
    {img:'../images/checkbox-content.png',status:'Content', pos:'0'},
    {img:'../images/checkbox-creative.png',status:'Creative', pos:'1'},
    {img:'../images/checkbox-develop.png',status:'Develop', pos:'2'},
  ];

  var projStatusImg = 'textLabel'+i;
  projStatusImg = Titanium.UI.createImageView({
    url: cb[s].img,
    pos: cb[s].pos,
    btn: 'statusBtn',
    indx: count
  });

  projStatusImgLabel.add(projStatusImg);
  projStatusView.add(projStatusImgLabel);
  projStatusView.add(projStatusLabel);
  projRow.add(projStatusView);
}
— asked April 23rd 2010 by Kelly Redd
  • images
0 Comments

1 Answer

  • On each iteration you are overwriting the projStatusImg, so the other ones become "anonymous".
    make an array with this images, and when you click on one image, walk in this last array, uncheck all that are not the one you are interested in, and check the active one.

    var img_array = [];
    
    for(s=0;s<=4;s++){
    // stuff
    projStatusImg = Titanium.UI.createImageView({....
    
    img_array.push(projStatusImg);
    
    //stuff
    
    — answered April 24th 2010 by Dan Tamas
    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.