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
Developer
connyhald
Posts: 102
Registered: ‎06-03-2012
My Device: Playbook
My Carrier: *

Top and bottom element in ListView

Hi,

 

is there a way to add one element at the very beginning of a list and one element at the very end? In QtQuick the ListView has a header and footer property. Something like this I'm looking for.

 

Thanks,

Conny

 

-----------
http://kodira.de
BB Apps: Pattern :: Plonk
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Top and bottom element in ListView

I'm not sure if there's a better way, but since (unlike with the QtQuick one?) you can specify arbitrary types for the individual items in your list model, you should be able to create the same effect by inserting, for example, a "header" and "footer" type item in the list at the start and end. Yes, it requires you to manage their position, but maybe that's okay in your case.

I've held off really digging deep into the list stuff yet so I don't know if there's a more direct solution.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
connyhald
Posts: 102
Registered: ‎06-03-2012
My Device: Playbook
My Carrier: *

Re: Top and bottom element in ListView

Thanks Peter, that sounds like a possible solution. As I'm having my own C++ list model it should be possible to insert 2 fake elements with fixed positions. I'll give it a try.

 

Or maybe I can detect if the list is on the very top or very bottom and then insert elements into the UI?! My use case is something like "load next 20 items".

 

Well, I'll dig a bit deeper. If I find something useful, I'll report back here.

 

-----------
http://kodira.de
BB Apps: Pattern :: Plonk
Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Top and bottom element in ListView

ListView has a leading visual property which you can add a c++/qml control to which is always there. there is nothing specifically there to keep something at the bottom of course you could write a simple method to always insert before length-1

Like all of my posts
Please use plain text.
Regular Contributor
wibi_okezone
Posts: 51
Registered: ‎04-24-2013
My Device: Z10
My Carrier: Telkomsel

Re: Top and bottom element in ListView

could u show sample code, because i want to add like a button at the bottom of list view, but not the menu context.

Thanks

Please use plain text.
Regular Contributor
asifmunir
Posts: 51
Registered: ‎08-07-2013
My Device: blackberry z10
My Carrier: asif

Re: Top and bottom element in ListView

 listItemComponents: [

                    ListItemComponent {

                        type: "header"

                        Container {

                            preferredWidth: 768

                            Label {

                                text: "Name:"

                                textStyle.color: Color.create("#018bb0")

                                translationX: 20

                            } 

                            Label {

                                text: "Email:"

                                textStyle.color: Color.create("#018bb0")

                                translationX: 20

                                translationY: -20

                            } 

                            Label {

                                text: "Mobile:"

                                textStyle.color: Color.create("#018bb0")

                                translationX: 20

                                translationY: -40

                            } 

                        }

                    },

                    ListItemComponent {

                        type: "item"

                        AddTo_cart { 

                        }

                    }

you can add header on page 

Please use plain text.