Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Getting only one array value in drop down list

$
0
0

Titanium SDK : 3.5.0 Alloy framework Platform : IOS

Hi Iam new to alloy framework and Iam creating a drop downlist. Below is my code. I am getting only one array value that too the last value, can anyone help me.

index.xml

<View id="viewmenu" borderWidth="1" borderColor="#000" height="20" top="42" left="5%" width="250">
            <ImageView id="arrow" backgroundImage="/images/1downarrow.png" right="0" height="30" width="30" bottom="0"></ImageView>
            <Label id="selectedItem">--Select--</Label>
        </View>
index.tss
"#viewcontainer":{
    height : '50',
    width : '250',
    left:'5%',
    contentHeight : "auto",
    contentWidth : "auto",
    showVerticalScrollIndicator:true,
    showHorizontalScrollIndicator:false,
    top : "50+20",
    visible : false,
    borderColor : "gray",
    //layout : "vertical",
},
"#item":{
    textAlign:'center',
    backgroundImage:'/images/drop-down-list-last-btn.png',
    height : '20',
    width : '250'
},
index.js
$.viewmenu.addEventListener('click',function(e){
    $.viewcontainer.show();
});
 
var array = ["one","two","three"];
 
var itemView = $.item;
for (var i=0;i<array.length;i++){
    itemView.text = array[i];
 
     itemView.addEventListener('click',function(e){
        $.viewmenu.children[0].text=this.text;
        $.viewcontainer.hide();
    });
 
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>