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
Developer
SuhairZain
Posts: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Populate a standard list

Hi, I want to use a standard listview in my app, including an image, title and description. I've used the following code to add data to the listview's datamodel. But only the description text comes up as the title of the listitem.

 

QVariantMap map;

map["title"] = QString("Title text");
map["description"] = QString("Description text");
map["image"] = QUrl("asset:///images/covered.png");
map["status"] = QString("done");
dataModel->append(map);

 what should i do, i use only c++, for the design as well as logic.

Please use plain text.
Developer
BBSJdev
Posts: 6,098
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Populate a standard list

That bit is fine can you post the ListItem code.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
SuhairZain
Posts: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Populate a standard list

I have not used any list item. I simply created a list view and assigned a data model to it. Please tell me if I need to use a list item provider and how to get it in the standard list view style.
Please use plain text.
Retired
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Populate a standard list

You generally need a "type" assigned to each list item to get a Header or Standard component, but it depends on the data model. Really, it comes down to the dataModel::itemType() method.

 

Your best bet is to read the "Default List Visuals" section here: https://developer.blackberry.com/native/reference/cascades/bb__cascades__listview.html

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Please use plain text.
BlackBerry Development Advisor
sabdelsayed
Posts: 249
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: Populate a standard list

[ Edited ]

Hi SuahirZain,

 

Here's how your StandardListItem ListItemComponent definition should look like:

ListItemComponent {                    
    type: "item1"
    StandardListItem {
        title: ListItemData.text
        description: ListItemData.description
        status: ListItemData.status
        imageSource: "images/" + ListItemData.image
     }
}

And that's how your associated model (assuming an xml model in this case) would probably look like:

<root>
<item1 status="New" description="Breaking News" text="News" image="images/news.png"/>
<item2 status="New" description="Tech News" text="Technology" image="images/tech.png"/>
<item1 status="Updated" description="Headlines News" text="News" image="images/news.png"/>
</root>

 Your ListView will use the above StandardListItem component to display all items in the model with type "item1". For items of type "item2" you must define another ListItemComponent if you are looking to display them.

 

Hope that helps!

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.
Developer
SuhairZain
Posts: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Populate a standard list

Thanks for the help guys. I used C++ for the design as well as the implementation. So I had to use ListItemProvider, it's OK.

Please use plain text.