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

createPicker: action on selected row

$
0
0

Hello!!

I have a button that displays a picker which at the same time I would like that when the user clicks on an option it does something, as for example, "closes the window", example:

// Button and listener to close window
var close = Ti.UI.createButton({
    font : { fontSize : 8 },
    color: 'blue',
    title: 'Cerrar',
    width: 25,
    top: 20,
    left: 10
});
close.addEventListener('click',function(e){
    win.close();
});
 
// Button and listener that opens the picker
var Menu = Ti.UI.createButton({
   borderTop: true,
   borderWidth: 1,
   borderColor: "#888",
   backgroundColor: 'black',
   title: 'Menu',
   color : 'white',
   bottom: 10,
   left: 10,
   width: 25,
   height: 25
});
Menu.addEventListener('click',function(e)
{
 
    var picker = Ti.UI.createPicker({
      top:50
    });
 
    var data = [];
    data[0]=Ti.UI.createPickerRow({title:'Bananas'});
    data[1]=Ti.UI.createPickerRow({title:'Strawberries'});
    data[2]=Ti.UI.createPickerRow({title:'Mangos'});
    data[3]=Ti.UI.createPickerRow({title:'Grapes'});
    data[4]=Ti.UI.createPickerRow({title: 'Cerrar'},close); // <<---- Here I would like that when selected it closes the win with my listener "close", also i would like to add other actions to the other rows
 
    picker.add(data);
    picker.selectionIndicator = true;
 
    win.add(picker);
});
I appreciate very much whoever takes the time to solve my question, thank you :D

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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