使用Tianium的ListView实现国际化
我从我的ListView项目中得到重复的值,就像文本对文本一样 这是我的问题,我不确定是否会上传图像: 我的ListView代码是:使用Tianium的ListView实现国际化,listview,internationalization,titanium,Listview,Internationalization,Titanium,我从我的ListView项目中得到重复的值,就像文本对文本一样 这是我的问题,我不确定是否会上传图像: 我的ListView代码是: <ListView id="listView" defaultItemTemplate="template" onItemclick="menuOptions"> <!-- The Templates tag sets the ListView's templates property -->
<ListView id="listView" defaultItemTemplate="template" onItemclick="menuOptions">
<!-- The Templates tag sets the ListView's templates property -->
<Templates>
<!-- Define your item templates within the Templates tags or use the
Require tag to include a view that only contains an ItemTemplate -->
<ItemTemplate name="template">
<ImageView bindId="pic" id="icon" />
<Label id="petLabel" />
<Label id="needleLable" />
<Label id="heightControl"/>
</ItemTemplate>
</Templates>
<ListSection>
<ListItem id="petLabel" val="mascota" pic:image="/images/menu/footprint.png"/>
<ListItem id="needleLable" val="vacuna" pic:image="/images/menu/pet.png"/>
<ListItem id="heightControl" val="estadistica" pic:image="/images/menu/pet.png"/>
</ListSection>
</ListView>
我不知道为什么会发生这种情况,我尝试了很多事情,但我无法解决,任何想法都是有用的
多谢各位
其他信息:
我执行了一个警报,当我单击ListItem时,该警报会返回以下内容:
{properties={height=100dp,accessoryType=0,textAlign=center,font={fontWeight=bold,fontSize=30,fontFamily=clear sans.light},title=Ver Vacunas,val=vacuna,id=needlable},pic={image=/images/menu/pet.png}
标题显示了正确的文本,但问题仍然存在。这可能是布局问题 尝试在ListView和ListSection元素中指定layout='vertical' 大概是这样的:
<ListView id="listView" defaultItemTemplate="template" onItemclick="menuOptions" layout='vertical'>
....
<ListSection layout='vertical'>
我在政府文件中发现: 您可以通过XML属性指定本地化 因此,我修改了.xml代码:
<ListView id="listView" defaultItemTemplate="template" onItemclick="menuOptions">
<!-- The Templates tag sets the ListView's templates property -->
<Templates>
<!-- Define your item templates within the Templates tags or use the
Require tag to include a view that only contains an ItemTemplate -->
<ItemTemplate name="template">
<ImageView bindId="pic" id="icon" />
<Label bindId="label" id="petLabel" />
</ItemTemplate>
</Templates>
<ListSection>
<ListItem label:text="L('itemPet')" val="mascota" pic:image="/images/menu/footprint.png"/>
<ListItem label:text="L('itemNeedle')" val="vacuna" pic:image="/images/menu/pet.png"/>
<ListItem label:text="L('itemHeight')" title="" val="estadistica" pic:image="/images/menu/pet.png"/>
</ListSection>
</ListView>
现在它工作正常了这几个字很神奇:label:text=L'itemPet'感谢您回答Funtik,我尝试在ListView和ListSection元素中指定layout='vertical',但不幸的是,它没有工作
'#petLabel':{
textAlign: Titanium.UI.TEXT_ALIGNMENT_CENTER,
text:L('itemPet'),
font:{
fontSize:30,
fontWeight:'bold',
fontFamily:'clear-sans.light'
}
}
'#needleLable':{
textAlign: Titanium.UI.TEXT_ALIGNMENT_CENTER,
text: L('itemNeedle'),
font:{
fontSize:30,
fontWeight:'bold',
fontFamily:'clear-sans.light'
}
}
'#heightControl':{
textAlign: Titanium.UI.TEXT_ALIGNMENT_CENTER,
text:L('itemHeight'),
font:{
fontSize:30,
fontWeight:'bold',
fontFamily:'clear-sans.light'
}
}
<ListView id="listView" defaultItemTemplate="template" onItemclick="menuOptions" layout='vertical'>
....
<ListSection layout='vertical'>
<ListView id="listView" defaultItemTemplate="template" onItemclick="menuOptions">
<!-- The Templates tag sets the ListView's templates property -->
<Templates>
<!-- Define your item templates within the Templates tags or use the
Require tag to include a view that only contains an ItemTemplate -->
<ItemTemplate name="template">
<ImageView bindId="pic" id="icon" />
<Label bindId="label" id="petLabel" />
</ItemTemplate>
</Templates>
<ListSection>
<ListItem label:text="L('itemPet')" val="mascota" pic:image="/images/menu/footprint.png"/>
<ListItem label:text="L('itemNeedle')" val="vacuna" pic:image="/images/menu/pet.png"/>
<ListItem label:text="L('itemHeight')" title="" val="estadistica" pic:image="/images/menu/pet.png"/>
</ListSection>
</ListView>