Titanium 钛:传递变量不起作用
试图将参数传递给addevent,但无效 把桌子放在一起:Titanium 钛:传递变量不起作用,titanium,titanium-mobile,Titanium,Titanium Mobile,试图将参数传递给addevent,但无效 把桌子放在一起: for (var i=0; i<json.objects[0].tour.length; i++){ var row = Ti.UI.createTableViewRow( title = json.objects[0].tour[i].name, leftImage = json.objects[0].tour[i].icon, hasChild =
for (var i=0; i<json.objects[0].tour.length; i++){
var row = Ti.UI.createTableViewRow(
title = json.objects[0].tour[i].name,
leftImage = json.objects[0].tour[i].icon,
hasChild = true,
rowIndex = json.objects[0].tour[i].id,
height = 68,
rowId = i
);
var tourdetdatattlwrvw = Ti.UI.createView({top:10, left: 10, width:'100%',height:28});
var tourdetdatattllbl = Ti.UI.createLabel({
text:json.objects[0].tour[i].name,
height:23,
width:'100%',
font:{fontSize:20,fontWeight:'bold'},
color:'#000',
textAlign:'left'
});
tourdetdatattlwrvw.add(tourdetdatattllbl)
var tourdetdatadescwrvw = Ti.UI.createView({left:10, width:'100%', top:40, height:60});
var tourdetdatadesclbl = Ti.UI.createLabel({
text:json.objects[0].tour[i].description,
font:{fontSize:12,fontWeight:'normal'},
color:'#000',
width:'100%',
height:60
});
tourdetdatadescwrvw.add(tourdetdatadesclbl)
row.add(tourdetdatattlwrvw);
row.add(tourdetdatadescwrvw);
tableData.push(row);
}
var table = Ti.UI.createTableView({
data:tableData
});
当然它不起作用了
我做错了什么?你为什么要试试这个
table.addEventListener('click', function(e) {
activeTour = e.index;
alert(e.index)
})
谢谢当您在行对象中设置任何自定义变量时,您可以通过下面的代码将其取回,所以请尝试一下,如果您发现任何问题,请告诉我
table.addEventListener('click', function(e) {
activeTour = e.row.rowId;
alert(e.row.rowId);
})
我认为你代码的以下部分有错误
var row = Ti.UI.createTableViewRow(
title = json.objects[0].tour[i].name,
leftImage = json.objects[0].tour[i].icon,
hasChild = true,
rowIndex = json.objects[0].tour[i].id,
height = 68,
rowId = i
);
试着把它改成
var row = Ti.UI.createTableViewRow({
title : json.objects[0].tour[i].name,
leftImage : json.objects[0].tour[i].icon,
hasChild : true,
rowIndex : json.objects[0].tour[i].id,
height : 68,
rowId : i
});
你可以把这个值当作
table.addEventListener('click', function(e) {
activeTour = e.rowData.rowId;
alert(activeTour);
});
希望对你有帮助。如果您有任何问题,请告诉我索引将适用于上一级别。因为我已经有1个屏幕了,我需要知道上一个家长(从第一次点击开始)才能让它工作。更准确地说,用户选择巡演,然后选择位置。它在选择旅游时效果很好,只是拒绝传递位置值。不,等等,我的错,这发生在旅游窗口上,所以我无法加载位置,因为我不知道我在哪一个旅游。。。
table.addEventListener('click', function(e) {
activeTour = e.rowData.rowId;
alert(activeTour);
});