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
Contributor
bit-brad
Posts: 31
Registered: ‎11-02-2012
My Device: Dev Alpha

Re: Listview within Scrollview causes near infinite scrolling

urbanglowcam, your situation is a bit different from the original issue. It sounds like you'll need this solution, but place your segmented control outside of the ListView, and not in the header. So your segmented control will not scroll at all. It will stay in a static position, but everything else will scroll.
Please use plain text.
Developer
urbanglowcam
Posts: 148
Registered: ‎10-30-2010
My Device: Bold 9930

Re: Listview within Scrollview causes near infinite scrolling

[ Edited ]

Thanks for the sample!

 

Hmm. The header image will be above the segmented control and changing elements below so this might be weird if everything scrolls but the segmented control. 

Please use plain text.
Developer
steve8820
Posts: 78
Registered: ‎04-04-2013
My Device: BB10 Dev Alpha Simulator

Re: Listview within Scrollview causes near infinite scrolling

Below is my code. May I know where should i put the code to set the listview's predefinedHeight? I saw your sample but cant find which part that sets the height. Please advice. Thank you.


ListView {
                        id: accTransListView
                        property int accno: selectedAcc.accno
                        rootIndexPath: [ accno ]

                        dataModel: XmlDataModel {
                            id: accTransHistoryDataModel
                            source: "../Model/transhistory.xml"
                        }
                        listItemComponents: [
                            ListItemComponent {
                                id: transHistoryListItem
                                type: "trans"
                                Container {
                                    layout: StackLayout {

                                    }
                                    preferredHeight: 50.0
                                    Container {
                                        layout: StackLayout {
                                            orientation: LayoutOrientation.LeftToRight

                                        }
                                        Container {
                                            layoutProperties: StackLayoutProperties {
                                                spaceQuota: 0.3
                                            }
                                            horizontalAlignment: HorizontalAlignment.Fill
                                            Label {
                                                text: ListItemData.transdate
                                                horizontalAlignment: HorizontalAlignment.Center
                                            }

                                        }
                                        Container {
                                            layoutProperties: StackLayoutProperties {
                                                spaceQuota: 0.4

                                            }
                                            leftPadding: 20.0
                                            Label {
                                                text: ListItemData.desc
                                            }

                                        }
                                        Container {
                                            layoutProperties: StackLayoutProperties {
                                                spaceQuota: 0.3

                                            }
                                            layout: DockLayout {

                                            }
                                            horizontalAlignment: HorizontalAlignment.Fill
                                            rightPadding: 20.0
                                            Label {
                                                text: ListItemData.amt
                                                horizontalAlignment: HorizontalAlignment.Right
                                            }
                                        }
                                    }
                                }
                            }
                        ]
                    }

Regards,

Steve Chan
Please use plain text.
Contributor
bit-brad
Posts: 31
Registered: ‎11-02-2012
My Device: Dev Alpha

Re: Listview within Scrollview causes near infinite scrolling

Remember that in the sample above I am NOT setting the height because I am not using that solution. The sample is a different (more preferred) solution.

 

ListView {

  onCreationCompleted: {

    accTransListView.preferredHeight = accTransListView.dataModel.size() * 50

  }

 


                        id: accTransListView
                        property int accno: selectedAcc.accno
                        rootIndexPath: [ accno ]

                       .....

Please use plain text.
Developer
steve8820
Posts: 78
Registered: ‎04-04-2013
My Device: BB10 Dev Alpha Simulator

Re: Listview within Scrollview causes near infinite scrolling

Thanks bit-brad, I tried this but still no working. Maybe I should try the preferred solution from your sample.
Regards,

Steve Chan
Please use plain text.
Developer
Kaz32
Posts: 236
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha

Re: Listview within Scrollview causes near infinite scrolling

Hi, I'm still facing this problem.

 

Is there any other solution than :

 - set listview height

 - make different UI item for the uppper part -> append to first item on listview.

 

When developing on Q10, I'm need can to scroll entire page and also on this page contain listview.

And the list item length is dynamic text from webservice so I cannot set item height. 

 

 

Thanks

Please use plain text.
Developer
Kaz32
Posts: 236
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha

Re: Listview within Scrollview causes near infinite scrolling

Hi, is there any other solution?

 

 

Thanks

Please use plain text.
Developer
testinz
Posts: 180
Registered: ‎09-03-2012
My Device: Blackberry 10

Re: Listview within Scrollview causes near infinite scrolling

Should this be considered a bug for Blackberry to fix?

Please use plain text.
Contributor
bit-brad
Posts: 31
Registered: ‎11-02-2012
My Device: Dev Alpha

Re: Listview within Scrollview causes near infinite scrolling

[ Edited ]

I don't think so. Use the preferred solution and this isn't an issue. In other words, "do not embed a list view in a scroll view".

Please use plain text.
Developer
RileyGB
Posts: 284
Registered: ‎08-06-2010
My Device: Z10

Re: Listview within Scrollview causes near infinite scrolling

I came up with a fairly simple solution to this today. It seems to work quite well.

 

ListView {
    id: myScrollViewList
    dataModel: ArrayDataModel {

    }
    listItemComponents: [
        ListItemComponent {
            StandardListItem {
                id: myStandardListItem
                title: ListItemData
                attachedObjects: [
                    LayoutUpdateHandler {
                        onLayoutFrameChanged: {
                            myStandardListItem.ListItem.view.updateListMaxHeight(layoutFrame.height);
                        }
                    }
                ]
            }
        }
    ]

    function updateListMaxHeight(height) {
        myScrollViewList.maxHeight = height * myScrollViewList.dataModel.size();
    }

    onCreationCompleted: {
        myScrollViewList.dataModel.append("Hi");
        myScrollViewList.dataModel.append("Hi1");
        myScrollViewList.dataModel.append("Hi2");
        myScrollViewList.dataModel.append("Hi3");
        myScrollViewList.dataModel.append("Hi4");
    }
}

 



Follow me on twitter @RileyGB - https://twitter.com/RileyGB
View my BB10 OpenSource projects - https://github.com/RileyGB/BlackBerry10-Samples
Please use plain text.