查看xml(列表视图模板)
<Alloy>
<ItemTemplate id="test">
<View onTouchstart="touch" width="Ti.UI.SIZE" height="Ti.UI.SIZE">
<Label>test</Label>
</View>
</ItemTemplate>
</Alloy>
控制器js
function touch(e){
Ti.API.debug('touch!!');
};
不只是安装Android ..(iOS很好)
并且在不使用ListView代码的情况下,android(和iOS)没问题。
<Alloy>
<Window class="container">
<View onTouchstart="touch" width="Ti.UI.SIZE" height="Ti.UI.SIZE">
<Label>test</Label>
</View>
</Window>
</Alloy>
我不知道有人解决方案吗?
答案 0 :(得分:1)
没有&#39; touchstart&#39; ListViews的方法,您可以使用&#39; dragstart&#39;并且&#39; scrollstart&#39;作为替代。
查看可用的活动:
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.ListView
我已尝试过一次添加“更改”#39;将事件发送到ItemTemplace内的TextField,但我要创建一个变通方法:
Change event on TextField inside ListView Template
如果无法实现,则必须使用&#39; itemclick&#39;并获取所选行:
$.list.addEventListener('itemclick',function(list) {
var row = $.list.sections[0].getItemAt(list.itemIndex);
if(row && row.title) {
row.title.text = 'hello world';
//when you click the View with 'cancel' bindId
if(list.bindId == 'cancel') yourCancelAction();
//when you click the View with 'save' bindId
//(if you need to pass the row index to the function,
//in order to update something on the clicked row with a external function)
if(list.bindId == 'save') yourSaveAction(list.itemIndex);
$.list.sections[0].updateItemAt(list.itemIndex,row);
}
list = row = null;
});