Hi, I need to make a picker as a navigation menu. When it selects an item, it should fire an event. In my case i want to change the top image. And when we click the selected picker value, it should do another event. That means i want to go to a sub menu. If we cant do this from this picker, Is there any other way to do this?
There is a practical example in the following app.
I don't know whether is done in Titanium or not, but that's what the clients after!
Many Thanks
1 Answer
Accepted Answer
hi,
You can get change event on picker , so you can do work on change event: here is an example for you :
var picker = Ti.UI.createPicker(); var data = []; data[0]=Ti.UI.createPickerRow({title:'1'}); data[1]=Ti.UI.createPickerRow({title:'2',custom_item:'s'}); data[2]=Ti.UI.createPickerRow({title:'3',custom_item:'m'}); data[3]=Ti.UI.createPickerRow({title:'4',custom_item:'g'}); // turn on the selection indicator (off by default) picker.selectionIndicator = true; picker.add(data); win.add(picker); picker.addEventListener('change', function(e) { var val = e.row.title; switch(val) { case "1": label.text = "Hi I am One"; break; case "2": label.text = "Hi I am Two"; break; case "3": label.text = "Hi I am Three"; break; case "4": label.text = "Hi I am Four"; break; } });If you want to know the selected value on the button or any other component click :
You can do a picker.getSelectedRow(0). the params that you pass to getSelectedRow is the column number in a case you havent assign any column just pass 0.
Hope this helps you.
Your Answer
Think you can help? Login to answer this question!