Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
MrGremlin
Posts: 2
Registered: ‎06-28-2013
My Device: BB10
Accepted Solution

How do I add an item to the ListView

I have a very basic question. I would like to read data from xml into the ListView, then add an item to the list and store it to the xml again. How can I do that?

 

ListView {

            id: listViewCustomUrl

            objectName: "listViewCustom"

            dataModel: XmlDataModel {

                source: "dataCustom.xml"

            }

}

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How do I add an item to the ListView

welcome to the support forums.

the xmldatamodel is static (first line of the API docs). for a dynamic model you would use one of the other classes.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
YamilBracho
Posts: 713
Registered: ‎05-31-2010
My Device: 8520

Re: How do I add an item to the ListView

First of all, your xml must be in a read/write folder in your app directory, say data, for example.

Next you can use a DataModel in memory (GroupDatModel), fill with XMLcontents, do any number of updates to this model and then when your exit or using a option persist it to the xml file.

Check the Persistent Objects example in http://blackberry.github.io/Cascades-Samples/persistentobjects.html