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

Super Contributor
Posts: 398
Registered: ‎01-12-2011
My Device: Q10
My Carrier: Fido

Multiple ListItemProviders for one ListView?



Is it possible to have multiple ListItemProviders for a single ListView? I need one listview with multiple types of items. If I cannot use multiple ListItemProviders, how would I use a single ListItemProvider to handle varying items??



Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Multiple ListItemProviders for one ListView?

Can you give an example of the sort of data you want?  You can customize the actual list item used per type, depending on the data model you are using, meaing each item in the list can look completely different from anything else.


You can't really use separate providers though. What that would mean isn't really well defined.

Paul Bernhardt
Application Development Consultant

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Super Contributor
Posts: 398
Registered: ‎01-12-2011
My Device: Q10
My Carrier: Fido

Re: Multiple ListItemProviders for one ListView?

Thanks for the reply,


An example would be a list of events:


First item: Dinner Event, height of 170.0f and background is light blue, shows a title, and up to 3 lines of descriptive text.


Second item: Work Event, height of 200.0f and background is light green, shows a title, short description and an image showing the logo of which department it involves (ex: sales, IT, accounting, all)


Third item: Another work event


Fourth item: Note, height of 100.0f, background is light gray, shows only one line of text.


How would I go about customizing the list item used per type? That seems to be what I'm looking for, just not sure how to do it.

Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Multiple ListItemProviders for one ListView?

[ Edited ]



If you're using QML, assign diferent itemTypes to ListItemComponents. Create one component for dinner type event (itemType: "dinner"), another for work type event (itemType: "work") etc.

In ListView declare a JavaScript function named itemType which will return a proper item type for a given indexpath. ListView docs have some sample code for this:



If you're declaring the dataModel in C++, overload this function in DataModel subclass and return itemType from it instead:

virtual Q_INVOKABLE QString itemType (const QVariantList &indexPath)


Andrey Fidrya, @zmeyc on twitter