如何使用 XML 合金标记在钛金中的列表视图上设置事件
How to set events on Listview in Titanium using XML Alloy Markup
从这里我知道事件不能直接在ListView或ListItem(Data)上设置。但可以设置为下面的代码。
var listView = Ti.UI.createListView({
// …
templates: {
"simple": {
// …
events: {
"longpress": function (event) {
Ti.API.warn(event.itemId); // Works! ;)
}
}
}
}
});
但我的问题是如何使用 XML 标记进行设置。我的列表视图是这样的
<ListView id="messageList" onItemclick="openPagerMessageDetails" >
<Templates >
<ItemTemplate id="lstTemplate" name="messageListtemplate" >
<View id="myCustomView" ></View>
</ItemTemplate>
</Templates>
<ListSection id="lstSection" ></ListSection>
</ListView>
这很老了,但根据 Appcelerator Wiki,当您查看模板时,您可以通过添加onClick=""
像往常一样将事件侦听器添加到特定视图(我假设它也适用于其他事件)。
<Templates>
<ItemTemplate id="lstTemplate" name="messageListtemplate">
<View id="myCustomView" onClick="doClick" ></View>
</ItemTemplate>
</Templates>
相关文章:
- 如何将参数从列表视图中的项传递到模板
- 根据手机上是否存在文件,在jQuery mobile中动态填充列表视图
- 取消选择滚动启动时的所有列表视图项目
- 使用PhoneGap和jQuery Mobile在android设备上显示动态列表视图
- 通过格式化将jquery移动组件动态添加到列表视图中
- jqmobile列表视图中元素之间的间距相等
- 如何在Vue.js中使用列表视图
- jQuery移动列表视图和面板
- 剑道移动列表视图更改过滤器onclick
- Metro 应用程序中的列表视图项目单击
- 列表视图在Android上滚动断断续续且缓慢
- 我们可以在 CouchDB 中对排序列表视图进行排序吗?
- 用户控件内的 ASP 列表视图.如何在用户控件完全加载后触发 javascript
- 使 Windows 8 列表视图可编辑
- 如何使按钮的行为因选定的列表视图项而异
- 在PHP循环中动态创建jQuery列表视图
- jQuery访问列表视图->ul->李->span->img
- 带有砖石结构的轴网视图/列表视图
- 访问可扩展QML应用程序中的列表视图索引
- jquery-mobile的列表视图中的两个弹出窗口