嗨,我正在为选择器制作一个 eventListener。这是我的代码:
var YahooScreen = require("YahooScreen");
var ESPNScreen = require("ESPNScreen");
var CBSScreen = require("CBSScreen");
var ApiWin = Titanium.UI.createWindow({
backgroundColor : '#fff'
});
var ApiLabel = Titanium.UI.createLabel({
text : 'I am Fantasy Expert at',
top : '28%',
left : '10%',
right : '10%',
height: 'auto',
width : 'auto',
color : '#000',
font : { fontSize : 28,fontWeight : 'bold'},
textAlign : 'center'
});
ApiWin.add(ApiLabel);
var ApiPicker = Ti.UI.createPicker({
Top : '35%',
left : '25%',
width : '50%'
});
ApiPicker.addEventListener('change', function(e) {
if (e.row == 'Yahoo!') {
alert('I am in Yahoo')
} else if (e.row == 'ESPN') {
alert('I am in ESPN');
} else {
alert('I am in CBS')
}
});
var data = [];
data.push(Titanium.UI.createPickerRow({
title : 'Yahoo!'
}));
data.push(Titanium.UI.createPickerRow({
title : 'Espn!'
}));
data.push(Titanium.UI.createPickerRow({
title : 'CBS Sports!'
}));
ApiPicker.add(data);
ApiWin.add(ApiPicker);
ApiWin.open();
When Yahoo is selected Yahoo alert should be shown and likewise but it only showing I am in CBS alert could you solve this problem?
谢谢