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
Posts: 148
Registered: ‎04-08-2013
My Device: Blackberry 10
My Carrier: Blackberry

List view with tiles

[ Edited ]

In my app I want to create a page which contains sevearal tiles in a grid format.Each tile contains an image and several labels above that image.My assumption is that I can implement this using List View.Below is my code that I tried but I cant find the solution.

 

// Default empty project template
import bb.cascades 1.0

// creates one page with a label
Page 
{
    ListView 
    {
        dataModel: XmlDataModel 
        {
            source: "assets:///data.xml"

        }
        layout: GridListLayout {}
        listItemComponents: [
            ListItemComponent 
            {
                Container 
                {
                    id: rootContainer
                    background: back.imagePaint
                    attachedObjects: [
                        ImagePaintDefinition 
                        {
                            id: back
                            repeatPattern: RepeatPattern.X
                            imageSource: ListItemData.image
                        }
                    ]
                    layout: StackLayout {}
                    Label 
                    {
                        text: ListItemData.title

                    }//label

                }//container

            }//list view component
        ]
      

    }//list view

}//page

 and the XML file is as follows:

 

<contacts version="1.0">

        <contact>

                <title>Sr. Editor</title>

               <image>default.png </image>  

         </contact>

   

        <contact>

                 <title>Talent Scout</title>

                 <image>default.png </image>

         </contact>

</contacts>

 

 

I have included the image of the page that I want to create.The number of tiles are dynamic and each  tile will contain images in background and several labels

 

Plz help me out how to Implement this

 

 Tiles That I want to implement

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: List view with tiles

It will take a while for the image to get approved so you are better off giving a textual description of your problem alongside the picture.

 

However the approach you are using should work, postioning the labels can be done using the Translate properties or changing your layout to Absolute or Dock. Or both. Smiley Happy

 

P.S. It's good practice to place your models in a sub-folder.

 

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: List view with tiles

Looking to have anything scrollable (i.e another ListView, ScrollView, etc.) within a ListView is known to have problems presently. Proceed with caution.

 

http://supportforums.blackberry.com/t5/Cascades-Development/Listview-within-Scrollview-causes-near-i...

 

There's another thread on Vertical ListViews within Horizontal ListViews which I searched for but couldn't find, however having written some code to test this I'd say look for another solutiuon as it's unreliable currently.

 

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 148
Registered: ‎04-08-2013
My Device: Blackberry 10
My Carrier: Blackberry

Re: List view with tiles

Thanks for your reply.But my actual problem is the code that I have added above is not at all working.While running the code Iam getting just a white screen.Plz help me what is wrong with the code.

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

Re: List view with tiles

Plz help me out.The problem is not with the scroll view.But the code that I tried above is not at all working.Plz help me
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: List view with tiles

Hi Sumi,

 

Sorry I don't have the time to answer individual emails, I usually just help out here when I need a break from my own coding.

 

The first thing I do when something isn't working the way I think it should is to check the log, this usually tells you what's wrong.

 

This looks like either a missing resource issue or scope issue to me and the log will let you know if either of these are the case.

 

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Highlighted
Developer
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30
My Carrier: T-Mobile

Re: List view with tiles

Check out the Stamp Collector sample, it uses a grid listview: https://github.com/blackberry/Cascades-Samples/tree/master/stampcollector

 

You don't have any gridlayout properties set. (not sure if this one matters)

 

Also taking a quick look how you defined your data model source, you have it as source: "assets:///data.xml" when I believe it should be just called as source: "data.xml" (assuming it is in the asset folder)

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan