Thursday, December 20, 2012

BB 10 Simple ListView

In BB 10 we can have  a custom list in our own way but firstly it is important that how we achieve the basic list for this purpose i wants to show an example of a basic listview, for this purpose Make a new Project with name HelloPractce and edit the main.qml  and just copy the following code


import bb.cascades 1.0
   
Page {
    content: Container {
        background: Color.White
        ListView {
           // rootIndexPath: [0]
            dataModel: XmlDataModel { source: "model.xml" }
        }
    }
}

after this step prepare a model.xml file and put inside the asset folder/directory

inside model.xml copy the code lines:


<model>
  <header title="Asia">
    <item title="India" />
    <item title="China" />
     <item title="Afghanistan" />
    <item title="SriLanka" />
     <item title="Pakistan" />
    <item title="Bangladesh" />
  </header>
  <header title="Europe">
    <item title="England" />
    <item title="France" />
     <item title="Spain" />
    <item title="Germany" />
     <item title="Holand" />
    <item title="Turkey" />
  </header>
</model>

now simply run the program. we can see the desired output as follows



No comments:

Post a Comment