cancel
Showing results for 
Search instead for 
Did you mean: 

how to get animateToItem() in a large scroll list

Eddie1066
Associate II

I'm trying to create a long vertical menu that can be configured for a different number of items. I have managed to get a working implementation with a single issue.

I would like to be able to select which item in the list is shown when the menu is loaded. For example, given a list of 30 items, I would like to go to Item 10 if it were the last item selected previously.

What I have tried:

Custom container scroll list with a custom container menu item. The scroll list is stored in a scrollable container to provide a scrollbar. For the scroll list to work with a long list, I have made the scroll list container's height long enough to fit 30 items within the designer. To force the list display to start from a specific point, I have tried  animateToItem()
which has no effect.

listMenuView.cpp

listMenuView::setupScreen() {
    scrollList1.setNumberOfItems(params->visibleItems);
    scrollList1.invalidate();
    scrollList1.initialize();
}

what is this the correct way to implement this behavior?

1 ACCEPTED SOLUTION

Accepted Solutions
JTP1
Lead

Hi Eddie

If I understand right your explanation about your configuration, you should scroll the scrollable container instead of scrollList.

Something like this:

scrollableContainer1.doScroll(0,(scrollList1ListItems[0].getHeight()*n)*-1); // n = index of first shown item
	

You can check the doScroll function parameters here 

https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_scrollable_container

Hope this helps.

Br JTP

 

 

View solution in original post

2 REPLIES 2
JTP1
Lead

Hi Eddie

If I understand right your explanation about your configuration, you should scroll the scrollable container instead of scrollList.

Something like this:

scrollableContainer1.doScroll(0,(scrollList1ListItems[0].getHeight()*n)*-1); // n = index of first shown item
	

You can check the doScroll function parameters here 

https://support.touchgfx.com/docs/api/classes/classtouchgfx_1_1_scrollable_container

Hope this helps.

Br JTP

 

 

Eddie1066
Associate II

Thanks a lot, JTP1! That worked. Much appreciated

Eddie