Reputation: 576
I have to do a list of people. This list have 2 fields, name and lastname.
I've created a listview, with a template like this :
<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>
This work on ios. But when i add item in list on android, the app is killed with an error.
This is my function who add the item :
function addEmptyItemPartenaire(){
$.partenairesListSection.appendItems([{
template:'template',
field_name:'',
field_lastname:'',
}]);
}
This is the console debug with errors :
[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)
Anyone can help me ?
Upvotes: 0
Views: 431
Reputation: 945
Remove defaultItemTemplate="template"
from ListView
and add template="template"
in ListSection
. Sometimes Android add random element to ListView
it can not be handled by defaultItemTemplate
Additionaly you can create default template:
<ItemTemplate name="defaultTemplate" height="0dp">
<View height="0dp">
</View>
</ItemTemplate>
Upvotes: 0
Reputation: 576
My problem is caused by the item object data :
$.partenairesListSection.appendItems([{
template:'template',
field_name:'',
field_lastname:'',
}]);
"field_name" and "field_lastname" are the bind id to my textfield. So, for set a value, i need to give it an object with a "value" properties :
{
template:'template',
field_name:{value:''},
field_lastname:{value:''},
}
Upvotes: 1