2014-01-29 70 views
1

我使用Android应用程序使用Titanium Appcelerator ..我试图单击并从我的表中检索行视图值。我得到 “未定义” ..help我找回我行值..Appcelerator Titanium TableRowView点击

这里是我的代码...

var row = Ti.UI.createTableViewRow(); 
row.title = 'row'; 
row.postid = '' + post.id; 
row.addEventListener('longclick', function(e) { 
    Titanium.API.info(evt.postid); 
}); 

回答

2

输入错误的参数名称,而不是:

row.addEventListener('longclick', function(e) { 
    Titanium.API.info(evt.postid); 
}); 

它应该是:

row.addEventListener('longclick', function(e) { 
    Titanium.API.info(e.postid); 
}); 

另外在TableView中和行的情况下,最好对整个表创建事件侦听器,像这样:

var table = Ti.UI.createTableView(); 
var row = Ti.UI.createTableViewRow(); 
row.title = 'row'; 
row.postid = '' + post.id; 
table.setData([row]); 

table.addEventListener('longclick', function(e) { 
    Titanium.API.info(e.row.postid); 
}); 
+0

感谢buddy .. it working .. – GaneshKumar

相关问题