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

Posts: 1,638
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

How to add and delete an item in a ListView?

[ Edited ]

In the QML I have a emply ListView object and then it is populated with some data on app startup.


When the user select a item I want to delete or when the user selects the Add button I want to add a new item the list.


Looked at the custom listview example and isn't want i wanted.  I just want to delete and insert a new item. 


Is this doable with the ListView object? I read in one post where suggested to reset the datamodel and then add it again.


Edit: in the Listview object there is a get DataModel().  Will try that.

Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to add and delete an item in a ListView?

ListViews all use a DataModel, generally a subclass and, in QML, likely one of ArrayDataModel or GroupDataModel. Each has its own techniques and functions for adding, inserting, deleting, and sometimes moving items around.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!