【发布时间】:2015-02-03 13:44:47
【问题描述】:
我必须列出人员名单。 此列表有 2 个字段,名称和姓氏。
我创建了一个列表视图,模板如下:
<ListView id="partenairesList" defaultItemTemplate="template">
<Templates>
<ItemTemplate name="template">
<View class="textField-demi">
<Label class="placeholder">Prénom</Label>
<TextField bindId="field_name"></TextField>
<View class="border-bottom textField-border"></View>
</View>
<View class="textField-demi textField-right">
<Label class="placeholder">Nom</Label>
<TextField bindId="field_lastname"></TextField>
<View class="border-bottom textField-border"></View>
</View>
</ItemTemplate>
</Templates>
<ListSection id="partenairesListSection">
</ListSection>
</ListView>
这项工作在 ios 上。 但是当我在 android 的列表中添加项目时,应用程序会因错误而被终止。
这是我添加项目的功能:
function addEmptyItemPartenaire(){
$.partenairesListSection.appendItems([{
template:'template',
field_name:'',
field_lastname:'',
}]);
}
这是有错误的控制台调试:
[WARN] : TiUIScrollView: (main) [137999,176598] Scroll direction could not be determined based on the provided view properties. Default VERTICAL scroll direction being used. Use the 'scrollType' property to explicitly set the scrolling direction.
[INFO] : I/dalvikvm-heap: Grow heap (frag case) to 15.674MB for 635812-byte allocation
[WARN] : dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40aa9300)
[ERROR] : TiApplication: (main) [28953,205551] Sending event: exception on thread: main msg:java.lang.ClassCastException: java.lang.String cannot be cast to java.util.HashMap; Titanium 3.2.0,2013/12/20 10:57,d9182d6
[ERROR] : TiApplication: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.HashMap
[ERROR] : TiApplication: at ti.modules.titanium.ui.widget.listview.TiListViewTemplate.updateOrMergeWithDefaultProperties(TiListViewTemplate.java:231)
[ERROR] : TiApplication: at ti.modules.titanium.ui.widget.listview.ListSectionProxy.processData(ListSectionProxy.java:432)
[ERROR] : TiApplication: at ti.modules.titanium.ui.widget.listview.ListSectionProxy.handleAppendItems(ListSectionProxy.java:492)
[ERROR] : TiApplication: at ti.modules.titanium.ui.widget.listview.ListSectionProxy.handleMessage(ListSectionProxy.java:236)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:137)
[ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:4931)
有人可以帮助我吗?
【问题讨论】:
-
这不是标准的 android sdk。抱歉,我无能为力。您应该在标题中包含钛
-
我在标题中添加了 Titanium,谢谢。
-
您在哪里定义“模板”?坐姿是什么样的?
-
我的“模板”在合金 xml 视图中定义。谢谢你的回复,我发现了我的错误。
标签: android forms listview titanium titanium-alloy