Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5821] ListView Template not working correctly on Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionNeeds more info
Resolution Date2018-08-13T19:19:37.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsStudio
Labelsn/a
Reporterrene@appsinteractive.com
AssigneeShak Hossain
Created2018-08-02T00:16:38.000+0000
Updated2018-08-13T19:19:38.000+0000

Description

The below code works in iOS and but not in Android, the elements in the childtemplate are not displaying in the Android emulator.
var myTemplate = {
    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: '70dp', height: '70dp', left: 0
            }
        },
        {                            // Title 
            type: 'Ti.UI.Label',     // Use a label for the title 
            bindId: 'info',          // Maps to a custom info property of the item data
            properties: {            // Sets the label properties
                color: '#000',
                font: { fontFamily:'Arial', fontSize: '20dp', fontWeight:'bold' },
                left: '80dp', top: 5,
            }
        },
        {                            // Subtitle
            type: 'Ti.UI.Label',     // Use a label for the subtitle
            bindId: 'es_info',       // Maps to a custom es_info property of the item data
            properties: {            // Sets the label properties
                color: 'gray',
                font: { fontFamily:'Arial', fontSize: '14dp' },
                left: '80dp', bottom: '5',
            }
        }
    ]
};
 
var listView = $.dynamicListView;
listView.templates={ 'plain': myTemplate};
listView.defaultItemTemplate="plain";


for (var i = 0; i < cats[0].category.length; i++) {
    
    var section = Ti.UI.createListSection({ headerView: createCustomView(cats[0].category[i].name)});
    
    //Ti.API.info(tasks[0].category[i].name);
    //clear data
	var data = [];
    
    for (var d = 0; d < cats[0].category[i].data.length; d++) {
    data.push({

        pic : { image : cats[0].category[i].data[d].image },
        info : { text: cats[0].category[i].data[d].name },
        es_info : { text : cats[0].category[i].data[d].description },

        // Sets the regular list data properties
        properties : {
            itemId: cats[0].category[i].data[d].id,
            name: cats[0].category[i].data[d].name,
            description: cats[0].category[i].data[d].description,
            image: cats[0].category[i].data[d].image,
            video: cats[0].category[i].data[d].video,
            videoURL: cats[0].category[i].data[d].videoURL,
            audio: cats[0].category[i].data[d].audio,
            audioURL: cats[0].category[i].data[d].audioURL,
            storeid: cats[0].category[i].data[d].storeid
        }
    });
 }
 
section.setItems(data);
//sections.push(section);
listView.appendSection(section);

Attachments

FileDateSize
Android_Emulator_-_Pixel_API_24_5554.png2018-08-02T00:15:18.000+000096962

Comments

  1. Hans Knöchel 2018-08-03

    I think parts of your example is missing, like the declaration of cats. Can you provide a standalone example that fits in an app.js?
  2. rene@appsinteractive.com 2018-08-03

    Here is cat which includes JSON. var cats = [ { "category": [ { "name": "Category", "data": [ { "id": "3", "name": "Sample1", "description": "", "video":"", "videoURL":"", "audio":"sample.mp3", "audioURL":"https://www.dropbox.com/", "image":"video-icon.png", "type":"audio", "storeid":"sample1" }, { "id": "4", "name": "Sample2", "description": "", "video":"", "videoURL":"", "audio":"sample2.mp3", "audioURL":"https://www.dropbox.com/", "image":"video-icon.png", "type":"audio", "storeid":"sample2" }, { "id": "4", "name": "sample3", "description": "", "video":"", "videoURL":"", "audio":"sample3.mp3", "audioURL":"/sample3.mp3", "image":"video-icon.png", "type":"audio", "storeid":"sample3" } ]} ] } ];
  3. Sharif AbuDarda 2018-08-06

    Hello, We need a full reproducible sample code in an app.js file or as a sample project. Thanks.

JSON Source