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
Posts: 19
Registered: ‎03-05-2013
My Device: 9700
My Carrier: BlackBerry
Accepted Solution

Listview Issue : scrolling not stop

Hello Friends,

 

 

I am getting some issue with ListView within ScrollView that ListView does not stop scrolling.

 

I want to put some some views (such as Label,Image textArea) in vertical stack layout container & add a ListView at the end of container, so that all views can scrolls .

 

But I get unexpected result that everything is ok but my list view does not stop scrolling event its list item scrolled.

 

If I add some other view such as Label after ListView then it never reached.

 

Can someone give me solution for this.

 

Thanks in Advance

 

I use the below code for QML

 

import bb.cascades 1.0

Container {

    background: Color.Yellow
    maxHeight: 1000
    preferredHeight: 1000
    ScrollView {
        maxHeight: 1000
        preferredHeight: 1000
        Container {
            Container {
                topPadding: 10
                leftPadding: 10
                rightPadding: 10

                Container {
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
                    TextField {
                        hintText: qsTr("ToSmiley SadEmail/Mobile Number)")
                    }
                    ImageButton {
                        defaultImageSource: "images/add.png"
                        pressedImageSource: "images/add_focus.png"
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                    }
                }
                Container {
                    topMargin: 10
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
                    ImageView {
                        preferredWidth: 120
                        preferredHeight: 90
                    }
                    TextArea {
                        maximumLength: 50
                        hintText: "Title"
                        preferredHeight: 180
                    }
                }
                background: Color.LightGray
                preferredHeight: 720
            }

            ListView {
                dataModel: ArrayDataModel {
                    id: contacts
                }
            }

            onCreationCompleted: {
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
            }
        }
    }
}

Highlighted
Developer
Posts: 79
Registered: ‎04-04-2013
My Device: BB10 Dev Alpha Simulator
My Carrier: Blackberry

Re: Listview Issue : scrolling not stop

As far as I know, using listview within scrollview will cause infnite scrolling. To solve this, try set the height of the listview. You can also try setting the listview height based on your number of records using contacts.size();

Hope it helps.
Regards,

Steve Chan
Contributor
Posts: 19
Registered: ‎03-05-2013
My Device: 9700
My Carrier: BlackBerry

Re: Listview Issue : scrolling not stop

Thanks Steve i did the same.

Contributor
Posts: 11
Registered: ‎05-30-2013
My Device: 9700
My Carrier: BlackBerry

Re: Listview Issue : scrolling not stop

Thax Steave , This also help me. I do the same.

Developer
Posts: 148
Registered: ‎04-08-2013
My Device: Blackberry 10
My Carrier: Blackberry

Re: Listview Issue : scrolling not stop

Hi R4BB and Steve,

Iam having the same issue and I tries contacts.size() but the count returned is 0.Below is my code.Plz help me out as u have already solved this.

 

Container {
    ScrollView {
        Container {
            Container {
                Container {
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
                    Label {
                        text: "item count = "+contacts.size()
                    }
                    ImageButton {
                        defaultImageSource: "images/add.png"
                        pressedImageSource: "images/add_focus.png"
                        verticalAlignment: VerticalAlignment.Center
                        horizontalAlignment: HorizontalAlignment.Center
                    }
                }
                Container {
                    topMargin: 10
                    layout: StackLayout {
                        orientation: LayoutOrientation.LeftToRight
                    }
                    ImageView {
                        preferredWidth: 120
                        preferredHeight: 90
                    }
                    TextArea {
                        maximumLength: 50
                        hintText: "Title"
                        preferredHeight: 180
                    }
                }
                background: Color.LightGray
                preferredHeight: 720
            }

            ListView {
                dataModel: ArrayDataModel {
                    id: contacts
                }
                preferredHeight: contacts.count() * 395
            }

            onCreationCompleted: {
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
                contacts.append("abac");
            }
        }
    }
}

 

Contributor
Posts: 19
Registered: ‎03-05-2013
My Device: 9700
My Carrier: BlackBerry

Re: Listview Issue : scrolling not stop

Hi SumiSadiq,

Actually it set preferredHeight only one time , I did it as

         dataModel: ArrayDataModel {
                        id: contacts
                        onItemAdded: {
                            lvContact.preferredHeight = size() * 100;
                        }
                        onItemRemoved: {
                            lvContact.preferredHeight = size() * 100;
                        }
                    }

 

I hope this will help you.