Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

ListView empty on Android

$
0
0

I have a listview that works on ios but on android the list item just displays the text "label"

https://www.dropbox.com/s/i9qflqwiz5l1jjr/Screen%20Shot%202013-06-07%20at%2010.21.03.png

events.xml

<Alloy>
    <View id="events" class="container">
        <ListView id="eventsList"/>
    </View>
</Alloy>
events.js
var section;
var plainTemplate = {
    childTemplates : [{// Image justified left
        type : 'Ti.UI.ImageView', // Use an image view for the image
        bindId : 'pic', // Maps to a custom pic property of the item data
        properties : {// Sets the image view properties
            width : '35dp',
            height : '35dp',
            left : '10dp',
            top : '15dp'
        }
    }, {// Title
        type : 'Ti.UI.Label', // Use a label for the title
        bindId : 'title', // Maps to a custom title property of the item data
        properties : {// Sets the label properties
            color : '#373e47',
            font : {
                fontFamily : Alloy.CFG.headingFont,
                fontSize : '21dp'
            },
            left : '55dp',
            top : '10dp',
            right : '10dp',
            height : '21dp',
        },
    }, {// Subtitle
        type : 'Ti.UI.Label', // Use a label for the subtitle
        bindId : 'date', // Maps to a custom subtitle property of the item data
        properties : {// Sets the label properties
            color : '#999999',
            font : {
                fontFamily : Alloy.CFG.headingFont,
                fontSize : '16dp'
            },
            left : '55dp',
            top : '30dp',
        }
    }],
};
 
$.eventsList.templates = { 'template': plainTemplate };
$.eventsList.defaultItemTemplate = 'template';
 
function loadEvents() {
    var eventData = [];
    plugevents.allEvents(60000, function(data) {
        if (data) {
            for (var i = 0; i < data.length; i++) {
                if (data[i].image) {
                    var image = data[i].image;
                } else {
                    var image = data[i].term_image;
                }
 
                eventData.push({
                    // Maps to the title component in the template
                    // Sets the text property of the Label component
                    title : {
                        text : data[i].title
                    },
                    // Maps to the subtitle component in the template
                    // Sets the text property of the Label component
                    date : {
                        text : data[i].date
                    },
                    // Maps to the pic component in the template
                    // Sets the image property of the ImageView component
                    pic : {
                        image : image
                    },
                    // Sets the regular list data properties
                    properties : {
                        itemId : data[i].nid,
                        data : data[i],
                        accessoryType : Ti.UI.LIST_ACCESSORY_TYPE_DISCLOSURE,
                        height: "65dp"
                    }
                });
            }
            section = Ti.UI.createListSection();
            section.setItems(eventData);
            $.eventsList.sections = [section];
        }
    });
}

Viewing all articles
Browse latest Browse all 7655

Trending Articles



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