[TIMOB-25390] Listview horizontal layout doesn't work
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Not Our Bug |
| Resolution Date | 2017-10-16T07:57:51.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | n/a |
| Reporter | nicolomonili |
| Assignee | Unknown |
| Created | 2017-10-13T15:21:34.000+0000 |
| Updated | 2018-08-06T17:52:09.000+0000 |
Description
*Test case*
var win = Ti.UI.createWindow();
var mytemplate = {
properties : {
layout : "horizontal"
},
childTemplates : [{
type : 'Ti.UI.Button',
bindId : 'btn1',
properties : {
width : 50,
height : 30,
left : 0,
color : "green"
}
},{
type : 'Ti.UI.Button',
bindId : 'btn2',
properties : {
width : 50,
height : 30,
left : 0,
color : "red"
}
},{
type : 'Ti.UI.Button',
bindId : 'btn3',
properties : {
width : 50,
height : 30,
left : 0,
color : "blue"
}
}]
};
var listview = Ti.UI.createListView({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
templates : {
'default' : mytemplate
},
defaultItemTemplate : 'default'
});
listview.sections = [Ti.UI.createListSection()];
var newData = [];
for(var i = 0 ; i < 10 ; i++){
newData.push({
btn1 : { title : "a " + 1 },
btn2 : { title : "b " + 1 },
btn3 : { title : "c " + 1 }
});
}
listview.sections[0].setItems(newData);
win.add(listview);
win.open();
*Actual result* : first screen shot
*Expected result* : second screen shot
Attachments
| File | Date | Size |
|---|---|---|
| Simulator Screen Shot - iPhone 5s - 2017-10-13 at 17.16.38.png | 2017-10-13T15:20:22.000+0000 | 33589 |
| Simulator Screen Shot - iPhone 5s - 2017-10-13 at 17.17.03.png | 2017-10-13T15:20:22.000+0000 | 47047 |
Hello, I was able to reproduce the issue for listview item. The layout property for templates is not working. Tested with Xcode 9 and SDK 6.2.2.GA.
Hey there! Is this only occurring with Xcode 9 and 6.2.2? I am seeing the same when using older SDK's (e.g. 6.1.x). Also, you apply the
layoutproperty to the list-item directly, which is not a supported (and not documented) property. You should always use a sub-view that has the horizontal layout and relate the other views to that one. Example:var win = Ti.UI.createWindow(); var mytemplate = { childTemplates : [{ type : 'Ti.UI.View', properties : { layout: 'horizontal' }, childTemplates : [{ type : 'Ti.UI.Button', bindId : 'btn1', properties : { width : 50, left : 0, color : "green" } },{ type : 'Ti.UI.Button', bindId : 'btn2', properties : { width : 50, left : 0, color : "red" } },{ type : 'Ti.UI.Button', bindId : 'btn3', properties : { width : 50, left : 0, color : "blue" } }] }] }; var listview = Ti.UI.createListView({ width : Ti.UI.FILL, height : Ti.UI.FILL, templates : { 'default' : mytemplate }, defaultItemTemplate : 'default' }); listview.sections = [Ti.UI.createListSection()]; var newData = []; for(var i = 0 ; i < 10 ; i++){ newData.push({ btn1 : { title : "a " + 1 }, btn2 : { title : "b " + 1 }, btn3 : { title : "c " + 1 } }); } listview.sections[0].setItems(newData); win.add(listview); win.open();Re TIMOB-24277, this is an Android-only behavior and should not even work in general (parity). Re the docs, the link references the Ti.UI.ListView docs, but the API used is the Ti.UI.ListItem (an item inside a section inside a list).
Ok. So this is not a bug. I will use a parent view as usual. Thank you
Thank you! Let us know if you see any other issues :-).
Closing as "not our bug". If you disagree, please reopen.