Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25390] Listview horizontal layout doesn't work

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionNot Our Bug
Resolution Date2017-10-16T07:57:51.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
Reporternicolomonili
AssigneeUnknown
Created2017-10-13T15:21:34.000+0000
Updated2018-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

FileDateSize
Simulator Screen Shot - iPhone 5s - 2017-10-13 at 17.16.38.png2017-10-13T15:20:22.000+000033589
Simulator Screen Shot - iPhone 5s - 2017-10-13 at 17.17.03.png2017-10-13T15:20:22.000+000047047

Comments

  1. Sharif AbuDarda 2017-10-13

    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.
  2. Hans Knöchel 2017-10-13

    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 layout property 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();
       
  3. nicolomonili 2017-10-16

  4. Hans Knöchel 2017-10-16

    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).
  5. nicolomonili 2017-10-16

    Ok. So this is not a bug. I will use a parent view as usual. Thank you
  6. Hans Knöchel 2017-10-16

    Thank you! Let us know if you see any other issues :-).
  7. Eric Merriman 2018-08-06

    Closing as "not our bug". If you disagree, please reopen.

JSON Source