Titanium Community Questions & Answer Archive

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

Generate Dinamic Views

Hey there!, how can I generate dynamic Views into a loop (for example) with variables in the variable name?

In the code below the variable what I need is "pX", where X is the variable.

var gallView_p1  = Titanium.UI.createView({
  top: 10,
  left: 10,
  height: 'auto',
  width: 'auto',
  opacity: 0.85
});

Thanks in advanced.

— asked August 4th 2010 by Esteban Fernandez
  • variables
  • views
0 Comments

2 Answers

  • Accepted Answer

    var views_arr=[];
    
    
    for (...) {
    var view =  Titanium.UI.createView({
      top: 10,
      left: 10,
      height: 'auto',
      width: 'auto',
      opacity: 0.85
    });
    
    views_arr.push(view)
    
    }
    

    then you access the view with

    views_arr[x]
    

    ~~~

    — answered September 14th 2010 by Dan Tamas
    permalink
    0 Comments
  • No one know how to do this ? I try with eval() but doesn't work:

    eval('var gallView_p + i = Titanium.UI.createView({');

    Any other idea ?…

    — answered September 14th 2010 by Esteban Fernandez
    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.