它给我提供了一个标签的未定义错误,带有id="somethinggooood“,但如果我在ListView之外创建标签,它可以毫无问题地访问它
是否有任何解决方法或任何其他方法来修复它?
Alloy.XML
<ListView id="userList"
defaultItemTemplate="user"
onItemclick="userProfile" >
<Templates >
<ItemTemplate bindId="user" name="user" >
<View backgroundColor="red" layout="vertical">
<Label bindId="name" />
<Label bindId="title" id="somethinggooood" />
//THIS IS WHAT I'D LIKE TO ACCESS
<ImageView id="goodb" bindId="img" />
</View>
</ItemTemplate>
</Templates>
<ListSection id="section" dataCollection="users" >
<ListItem template="user"
user:id="{id}"
img:image="{author_img}"
name:text="{adresse}"
title:text="{title}" />
</ListSection>
</ListView>JS
function goodfff(){
alert($.somethinggooood.text);
};发布于 2017-04-06 16:24:21
由于加载方式的原因,listview中的任何项都不能通过ID进行访问。您可以通过获取行本身从ListView中获取数据,然后您将获得用于设置视图的数据。
像这样动态更改它也是不可能的,您需要重新创建项目并使用新数据更新项目。
https://stackoverflow.com/questions/43244240
复制相似问题