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

ListView containing ScrollableView

$
0
0

This is the second question I post in a week about ListViews and ScrollableViews; but while the previous one is about a compilation error I got trying to use Alloy views, this one is more about trying to understand what Titanium actually supports in term of ListView templates.

The question: if I have a ScrollableView inside a template, how can I programmatically change/load its views? I tried putting the definition of the views inside the childTemplates property of the ScrollableView but it doesn't work as expected.

Following a snippet of code in which I try to push items into a list supposed to contain a ScrollableView; after that, a screenshot of the emulator showing something totally different from the expectations.

var template = {
    childTemplates: [
        {
            type: 'Ti.UI.ScrollableView',
            bindId: 'scrollable',
            childTemplates: [
                {
                    type: 'Ti.UI.View',
                    bindId: 'view1',
                    childTemplates: [
                        {
                            type: 'Ti.UI.Label',
                            bindId: 'label1',
                            properties: {
                                text: 'label1'
                            }
                        }
                    ]
                },
                {
                    type: 'Ti.UI.View',
                    bindId: 'view2',
                    childTemplates: [
                        {
                            type: 'Ti.UI.Label',
                            bindId: 'label2',
                            properties: {
                                text: 'label2'
                            }
                        }
                    ]
                }
            ]
        }
    ]
};
 
var list = Ti.UI.createListView({ templates: { t: template }, defaultTemplate: 't'});
 
list.setSections([Ti.UI.createListSection({
    items: [
        { scrollable: { view1: { label1: { text: 'foo' }}}},
        { scrollable: { view2: { label2: { text: 'bar' }}}}
    ]
})]);
$.win.add(list);
$.win.open();
Screenshot

It seems I am doing something terribly wrong.


Viewing all articles
Browse latest Browse all 8068

Trending Articles



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