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
Highlighted
New Developer
Posts: 19
Registered: ‎12-16-2013
My Device: bb Z10 / STL100-1
My Carrier: operotor
Accepted Solution

ListView - DockLayout Problem

here is my code

 

import bb.cascades 1.2
Page {
    Container {
           layout: DockLayout {}
                   
                Container {
                    verticalAlignment: VerticalAlignment.Top
                    horizontalAlignment: HorizontalAlignment.Fill
                    Button {
                        text: "1.button"
                        horizontalAlignment: HorizontalAlignment.Fill
                        
                    }
                }
                
                Container {
                    verticalAlignment: VerticalAlignment.Center
                                
                    ListView {
              
                        
                        dataModel: XmlDataModel {
                            source: "asset:///currencies.xml"
                        }
                    }
                
              
                
                }
                
        
                Container {
                    verticalAlignment: VerticalAlignment.Bottom
                    horizontalAlignment: HorizontalAlignment.Fill
               
                  Button {
                      text: "2. button"
                      horizontalAlignment: HorizontalAlignment.Fill
                     
                  }
                }
        
        
        
        
    }
}

 

when I use a list viev in a dock layout it dosent fit properly.instead, it collides with the first container.

shouldnt it be just after the first container since I set the verticallayout to center for the listview's parent container.

 

thanks in advance.

 

 

 

 

 

Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: ListView - DockLayout Problem

You need to set prefferedHeight of ListView if you want to center it.

 

BTW: Using DockLayout if you want Buttons on TOP/BOTTOM and ListView in Center is not good workaround. Better for you will be use StackLayout ToptoBottom



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 49
Registered: ‎05-31-2013
My Device: Z10, Passport

Re: ListView - DockLayout Problem

When using the dock layout object are added as layers and the order given in qml is important. Your code adds a listview on top of the first button. What happens is that you will not be able to capture gestures for that button and once populated, the listview will graphically overlay button 1.

Below is one valid approach for your intent:

import bb.cascades 1.2

Page {
    Container {
        layout: DockLayout {
        }
        
        Container {
            id: cont
            bottomPadding: 73
            verticalAlignment: VerticalAlignment.Top
            horizontalAlignment: HorizontalAlignment.Fill
            Button {
                bottomMargin: 0
                text: "1.button"
                horizontalAlignment: HorizontalAlignment.Fill
                onClicked: {
                    console.log("dsds");
                }
            }
            Container {
                //background: Color.Blue
                ListView {
                    dataModel: XmlDataModel {
                        source: "asset:///currencies.xml"
                    }
                }
            }
        }

        Container {
            verticalAlignment: VerticalAlignment.Bottom
            horizontalAlignment: HorizontalAlignment.Fill

            Button {
                text: "2. button"
                horizontalAlignment: HorizontalAlignment.Fill
                onClicked: {
                    console.log("da asdsa");
                }
            }
        }
    }
}