[AC-5821] ListView Template not working correctly on Android
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Needs more info |
Resolution Date | 2018-08-13T19:19:37.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Studio |
Labels | n/a |
Reporter | rene@appsinteractive.com |
Assignee | Shak Hossain |
Created | 2018-08-02T00:16:38.000+0000 |
Updated | 2018-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
File | Date | Size |
---|---|---|
Android_Emulator_-_Pixel_API_24_5554.png | 2018-08-02T00:15:18.000+0000 | 96962 |
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?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" } ]} ] } ];
Hello, We need a full reproducible sample code in an app.js file or as a sample project. Thanks.