Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

How to add item in ListView - simple question

$
0
0

Hello all I need your help to add data in listView. I follow the sample but I don t understand why my data don't go in the listView.

Here's the code :

// Create template
var plainTemplateAdress = {
    childTemplatesAdress: [
        {
            type: 'Ti.UI.Label', // Use a label
            bindId: 'adress',  // Bind ID for this label
            properties: {        // Sets the Label.left property
                top: 3,
        left: 10,
            }
        },
        {
            type: 'Ti.UI.Label', // Use a label
            bindId: 'city',  // Bind ID for this label
            properties: {        // Sets the Label.left property
                top: 6,
                left: 10,
        }
        },
    ]
};
 
var table = Ti.UI.createListView({
        templates: { 'plainAdress': plainTemplateAdress },
        defaultItemTemplate: 'plainAdress',
    top:20,
});
 
var data = [];
var sectionAdress = Ti.UI.createListSection();
 
table.removeAllChildren();
 
for (var i = 0; i < 10; i++) {
 
    data.push({
        adress : { text: "Test Adress " + i },
        city : { text: "Test City  " + i  },
    });
 
sectionAdress.setItems(dataAdress);
}
table.sections = [sectionAdress];
 
win.add(table);
I just follow the sample but don't understand why this is not working.

I think the problem is in this part of the code :

for (var i = 0; i < 10; i++) {
 
    data.push({
        adress : { text: "Test Adress " + i },
        city : { text: "Test City  " + i  },
    });
 
sectionAdress.setItems(dataAdress);
}
table.sections = [sectionAdress];

Anyone can help me ?

Many thanks


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>