gpt4 book ai didi

android - 具有数据收集功能的 Titanium ListViews

转载 作者:行者123 更新时间:2023-11-29 02:48:20 25 4
gpt4 key购买 nike

在我的钛应用程序中,我必须显示元素列表,为此我使用以下 View :

<Alloy>
<Collection src="featuredEvents"/>
<Window id="win" class="container" navBarHidden="true" exitOnClose="true" onOpen="showIndicator">
<View id="navView"></View>
<ActivityIndicator id="activityIndicator" message="L('loading')" />

<TableView id="featuredEvents" dataCollection="featuredEvents" dataFilter="filterEvents" opacity="0" class="list">
<TableViewRow eventId="{alloy_id}" onClick="showEvent">
<View class="event-wrapper">
<ImageView image="{img}" eventId="{alloy_id}" defaultImage="/img/loading.jpg"/>
<View class="eventImageOverlayYellow" eventId="{alloy_id}">
<Label id="eventName" text="{name}" eventId="{alloy_id}" />
<View id="eventTypeContainer" class="iconedLabelBig">
<ImageView image="{icon}" class="iconBig" />
<Label id="eventType" text="{type}" eventId="{alloy_id}" />
</View>
</View>
</View>
</TableViewRow>
</TableView>
</Window>
</Alloy>

它工作正常但在 android 上的性能真的很差,所以我想使用 ListView 而不是 TableView 重写相同的列表。这是我想出的:

<Alloy>
<Collection src="featuredEvents"/>
<Window id="win" class="container" navBarHidden="true" exitOnClose="true" onOpen="showIndicator">
<View id="navView"></View>
<ActivityIndicator id="activityIndicator" message="L('loading')" />

<ListView id="featuredEvents" dataCollection="featuredEvents" dataFilter="filterEvents" opacity="0" class="list">
<ListSection eventId="{alloy_id}" onClick="showEvent">
<ListItem class="event-wrapper">
<ImageView image="{img}" eventId="{alloy_id}" defaultImage="/img/loading.jpg"/>
<View class="eventImageOverlayYellow" eventId="{alloy_id}">
<Label id="eventName" text="{name}" eventId="{alloy_id}" />
<View id="eventTypeContainer" class="iconedLabelBig">
<ImageView image="{icon}" class="iconBig" />
<Label id="eventType" text="{type}" eventId="{alloy_id}" />
</View>
</View>
</ListItem>
</ListSection>
</ListView>
</Window>
</Alloy>

我的 Controller index.js:

function showIndicator(e){}
$.win.open();

当我运行它时,出现以下错误:

Location:
alloy/controllers/index.js

Message:
Uncaught typeError: cannot read property '_transform' of null

Source:
title:"undefined" != typeof $model__transform["name"] ? $model._

-有没有ListView结合合金数据采集使用的例子?

-知道这个错误是什么意思吗?

最佳答案

我今天也一直在努力使用ListView,所以我不是专家,但也许我可以提供帮助。我在这里阅读了有关 ListViewTableView 之间差异的文档:http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.ListView我还从这个问题中得到了一些很好的帮助,这是使用 Alloy 的 ListView 的少数示例之一。 Titanium Alloy ListView Nested Model Array of Tags

来自第一个链接中的文档:

ListItem 对象的创建方法与 TableViewRow 不同。 ListItem 是通过将 ListDataItem 对象数组传递到 ListSection 来创建的。

您无法使用 add 方法将 View 添加到 ListItem,而这可以使用 TableViewRow 来完成。要将 View 添加到 ListItem,您需要定义一个 ItemTemplate,它使用 template 属性绑定(bind)到列表数据项。

您无法显式设置 ListItem 的属性或绑定(bind)事件。您必须使用 ListDataItemItemTemplate 的属性字典以及 ItemTemplateViewTemplate 的事件字典来设置它们>,分别。

至于您的错误,当我尝试将变量直接传递到模板中时,我遇到了类似的错误,就像使用 TableRow 所做的那样。相反,我必须用额外的属性填充绑定(bind)到神庙的变量。不确定是否推荐这样做,但它确实有效。

关于android - 具有数据收集功能的 Titanium ListViews,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24839328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com