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: 15
Registered: ‎12-20-2012
My Device: BlackBerry 10 Dev Alpha
My Carrier: Rogers
Accepted Solution

Nested Containers in ScrollView

Hey guys,


I am making a list of Containers which I am trying to render to the screen, with the ability to scroll down through the list. I have a number of Containers, which are all added to a holding Container which I then put in a ScrollView. The holding Container is much too big for the screen, but does not allow scrolling, even inside of the ScrollView.


I know that there is already a ListView which does almost exactly what I need, but I need much more dynamic access to alter the list than ListView offers.


Here is a basic version of the code I am running:

Container* mainContainer = new Container();
Container* listContainer = new Container();

Container* headerContainer = new Container();
Label* headerLabel = new Label();

for(int i = 0; i < 100; i++){
	Label* label = new Label();
Container* labelContainer = new Container(); label->setText(QString::number(i));
labelContainer->add(label); listContainer->add(labelContainer); } ScrollView* scrollView = ScrollView::create().content(listContainer); mainContainer->add(headerContainer); mainContainer->add(scrollView); page->setContent(mainContainer);


If I just add the ScrollView straight to the page, without any parent containers then it renders fine and allows full scrolling through the list of Labels. However, once the ScrollView is added to the mainContainer and that is set as the Page's content, it no longer scrolls. 


Any suggestions?

Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10
My Carrier: Rogers

Re: Nested Containers in ScrollView

Hey there...


Actually, it is working. It's just that your ScrollView is as wide as the numbers are.. Or rather as wide as your label which holds the numbers... Try adding the following property to your ScrollView... 


	ScrollView* scrollView = ScrollView::create()