Android 将标签动态添加到ListViewItem中的视图中
在Appcelerator Titanium中,我的ListView示例有以下XML:Android 将标签动态添加到ListViewItem中的视图中,android,titanium-mobile,appcelerator-titanium,titanium-alloy,appcelerator-alloy,Android,Titanium Mobile,Appcelerator Titanium,Titanium Alloy,Appcelerator Alloy,在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="verti
<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"/>
这是一些演示数据,但这段代码在Android上的行为与在iOS上的不同
在iOS上,我得到了预期的结果。“信封”视图是一个绿色矩形,包含标签“first”。在Android上,这似乎不起作用。我只得到绿色矩形,但没有添加子项
知道如何解决这个安卓特定问题的人?如何向listview中的视图添加标签
使用XML向信封添加标签时(介于
和
之间),会显示标签。尝试使用“子对象”属性添加标签时,标签不会添加到视图中 children属性不应该工作,但在iOS中它会工作
我也遇到过同样的问题,在android中工作的唯一解决方案是在模板中包含标签
我提出了一个与此相关的问题:,在这种情况下,我也尝试过以这种方式将数据设置为TableView,但仍然没有成功
无论哪种方式,都不建议这样做
在您的情况下,我认为您不需要,但是如果您想知道所选的bindId,您不能,只能知道ItemTemplate中定义的视图和标签(使用Alloy)
return {
name: {text: object.name},
number: {text: object.number},
direction: {text: object.direction},
envelopes: { children: [Titanium.UI.createLabel({
text: "first",
width:'30dp',
height:'30dp'
})]}
}