【发布时间】:2017-01-04 19:06:31
【问题描述】:
在 Appcelerator Titanium 中,我的 ListView 示例有以下 XML:
<ListView class="fill-height" defaultItemTemplate="item">
<Templates>
<ItemTemplate name="item" height="100dp">
<View class="top-10 left-10 right-10 bottom-10" layout="vertical">
<View class="size-height fill-width">
<Label class="left title" bindId="name"/>
<Label class="right description" bindId="number"/>
</View>
<Label class="top-5 left fill-width description" height="13dp" bindId="direction"/>
<View width="100dp" height="40dp" layout="vertical" backgroundColor="green" bindId="envelopes">
</View>
</View>
</ItemTemplate>
</Templates>
<ListSection id="items"/>
我正在使用以下代码返回一些数据来填充我的 ListView:
return {
name: {text: object.name},
number: {text: object.number},
direction: {text: object.direction},
envelopes: { children: [Titanium.UI.createLabel({
text: "first",
width:'30dp',
height:'30dp'
})]}
}
这是一些演示数据,但这段代码在 Android 和 iOS 上会导致不同的行为。
在 iOS 上,我得到了预期的结果。 “信封”视图是一个包含标签“first”的绿色矩形。在 Android 上,这似乎不起作用。我只得到绿色矩形,但没有添加孩子。
知道如何解决这个 Android 特定问题的人吗?如何将标签添加到列表视图中的视图?
使用 XML 向信封添加标签时(在<View> 和</View> 之间),会显示标签。尝试使用 children-property 添加它时,标签不会添加到视图中。
【问题讨论】:
标签: android titanium-mobile appcelerator-titanium titanium-alloy appcelerator-alloy