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
Posts: 79
Registered: ‎02-04-2013
My Device: Z10 LE
My Carrier: Simobil

ListView Container and Label as Item

Hi guys,

 

I need to do something like this. Select multiple items in a ListView and whenever one of the item is touched, it should change background.

So for this case a Container as an item would be perfect. It has to be done in C++ !!!

 

I've been looking how this could be done, but didn't yet figure it out. Perhaps something like ListItemProvider, but I don't know exactly  how to use it.

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListView Container and Label as Item

[ Edited ]

The cascadescookbookcpp sample app is a good example of how to use ListItemProvider in C++.

 

Looking at your history it seems you do not know how to use the like button, to encourage others to continue to help please click on the 'like -thumbs up' button when someone has taken the time to answer you with something useful.  In your case I recommend going back and doing this on several of the posts you have created.  When a post has answered your initial question please mark one of the posts as a solution to tie it all up and help others who later have the same question.

 


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 79
Registered: ‎02-04-2013
My Device: Z10 LE
My Carrier: Simobil

Re: ListView Container and Label as Item

Will look at coockbook sample.


Thanks for the "like" note.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListView Container and Label as Item

You're welcome and it's good to see that superdirt now has the recognition he deserves. Smiley Happy


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 79
Registered: ‎02-04-2013
My Device: Z10 LE
My Carrier: Simobil

Re: ListView Container and Label as Item

Well I looked at the coockbook sample, and kind of modified that itemFactory and Item to suit my App, I removed the Image and keept Container and Label. But when I add this new factory to my App, I get nothing.(blank Container) I use ArraydataModel.

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListView Container and Label as Item

Okay. Well close this thread off then create a new one that includes the code you've written and we'll take a look to see where the problem is.

 


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 79
Registered: ‎02-04-2013
My Device: Z10 LE
My Carrier: Simobil

Re: ListView Container and Label as Item

Well the code is identical to cookbook, but in function onTriggered in this line throws error: request for member 'data' in 'model', which is of non-class type 'bb::cascades::ArrayDataModel*'

void TodoList::onTriggered(const QVariantList indexPath){
	//CustomControl *recipe = NULL;

	// Get the selected item title
	QVariantMap map = model.data(indexPath).toMap(); // the line of error
	QString title = map.value("title").toString();
.

.
.
.
.
.

}

 

model is initialized in App.hpp  and retrieved by findchild in App.cpp

I assume that in "onTriggered" titles  are read ?

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListView Container and Label as Item

Yes but where have you declared model for the TodoList class?

Is it a member variable?

 


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 79
Registered: ‎02-04-2013
My Device: Z10 LE
My Carrier: Simobil

Re: ListView Container and Label as Item

App==TodoList

 

So in hpp is:

bb::cascades::ArrayDataModel *model;

 And in .cpp is:

TodoList::TodoList(bb::cascades::Application *app)
: QObject(app)
{
.
.
.
model = root->findChild<ArrayDataModel*>("listmodel");
.
.
.
.

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ListView Container and Label as Item

Could you post a bit more (read a lot more) of the code otherwise it's just going to be endless 'have you done this' questions.

 

Do you check to see if findChild returns anything?

 

 


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

Developer of stokLocker, Sympatico and Super Sentences.