Titanium Adding custom template to a listview -
Titanium Adding custom template to a listview -
i'm building application titanium studio , alloy. in 1 of windows, i'm trying dynamically add together listitem in listview pressing button (allowing user retrieve image or file).
i need add together listitem particular structures : image supposed show datatype, label file name, , image delete listitem. here template :
lignefichier.xml
<alloy> <itemtemplate name="lignefichier" id="lignefichier"> <view class="item-container"> <imageview bindid="typedonnee" /> <label bindid="nomfichier" /> <imageview bindid="supprimer" /> </view> </itemtemplate> </alloy>
and then, in controller of page :
mycontroller.js
var info = []; var tmp = { typedonnee : { image : '/images/image.png' }, nomfichier : { text : event.media.file.name }, supprimer : { image : '/images/supprimer.png' } //i tried utilize line : //template: 'lignefichier', //but tells me template undefined }; data.push(tmp); //my listview $.listefichiers.sections[0].items = $.listefichiers.sections[0].items.concat(data);
so tried link template alloy straight :
<listview id="listefichiers" height="100" headertitle="" template="lignefichier"> <listsection id="photo" headertitle=""> </listsection> <listsection id="audio" headertitle=""> </listsection> </listview>
but, when add together line, doesn't utilize template, doesn't find text, write 'label'. , then, in console, there message :
please utilize 'properties' binding builtintemplate
so tried replace binding name 'properties' no success... mean someone? not hesitate inquire precisions or tell me if forgot sample.
i think alloy can't recognize template because defined in separate file. seek define in same file :
<listview id="listefichiers" height="100" headertitle="" defaultitemtemplate='lignefichier'> <templates> <itemtemplate name="lignefichier" id="lignefichier"> <view class="item-container"> <imageview bindid="typedonnee" /> <label bindid="nomfichier" /> <imageview bindid="supprimer" /> </view> </itemtemplate> </templates> <listsection headertitle="title"> <listitem typedonnee:image="yourimage.png" nomfichier:text="filename" supprimer:image="supprimer.png" /> </listsection> </listview>
edit : can utilize require add together template :
in templatename.xml :
<alloy> <itemtemplate name="lignefichier" id="lignefichier"> <view class="item-container"> <imageview bindid="typedonnee" /> <label bindid="nomfichier" /> <imageview bindid="supprimer" /> </view> </itemtemplate> </alloy>
then add together listview templates
<listview id="listefichiers" height="100" headertitle="" defaultitemtemplate='lignefichier'> <templates> <require src="templatename"/> </templates> <listsection headertitle="title"> <listitem typedonnee:image="yourimage.png" nomfichier:text="filename" supprimer:image="supprimer.png" /> </listsection> </listview>
i have tested :)
listview titanium-alloy
Comments
Post a Comment