Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1455] Can't set position of a slider which is a child of a ListView

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2015-07-21T20:27:39.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid
ReporterChristian Waldmann
AssigneeRadamantis Torres-Lechuga
Created2015-06-08T12:37:32.000+0000
Updated2016-03-08T07:37:53.000+0000

Description

Environment

Operating System Name = Mac OS X Version = 10.10.3 Node.js Node.js Version = 0.12.1 npm Version = 2.5.1 Titanium CLI CLI Version = 3.4.2 Titanium SDK SDK Version = 3.5.1.GA Target Platform = android

Example Code

var templates = {
    slider :{
        childTemplates: [
            {
                type: 'Ti.UI.ImageView', 
                allowsSelection: false,
                properties: {             
                    left: '10dp'
                }
            },
            {
                type: 'Ti.UI.Slider',
                events : {
                    touchend : function(e) {
                        var slider = e.source;

                        slider.value = Number((slider.value).toFixed(0));
                    }
                },

                properties: {
                    width: 160,
                    left : 100,
                    paddingLeft: 10,
                    min : 0,
                    max : 2,
                    value : 1
                }
            }
        ]
    }
};

var listView = Ti.UI.createListView({
    top : 0,
    templates : templates,
    defaultItemTemplate : 'slider'
});

var sections = [];
var section = Ti.UI.createListSection();
var items = [];
sections.push(section);

for(var i = 0; i < 1; i ++) {
    console.warn('add ' + i);
    items.push({
        template : 'slider',
        bindID: '' + i
    });
}

section.appendItems(items);

listView.sections = sections;

$.win.add(listView);

$.win.open();

Expected behavior

The silder position snapp to the set position after the touch end

Current behavior

The silder doesn't move.

Comments

  1. Christian Waldmann 2015-06-10

    Same problem with 4.0.0.GA
  2. Motiur Rahman 2015-07-01

    Hello We can set a position of a slider which is a child of listView. We did not get any unwanted behaviour. *Testing Environment* CLI: 4.0.2 Ti SDK: 4.0.0.GA, Android:4.4.4, 4.2.2, 5.0.1 *Test Code*
       var win = Ti.UI.createWindow({
       	backgroundColor : 'white'
       });
       var templates = {
       	slider : {
       		childTemplates : [{
       			type : 'Ti.UI.ImageView',
       			allowsSelection : false,
       			properties : {// Sets the ImageView.image property
       				left : 5,
       				image : 'KS_nav_ui.png',
       				width : 50,
       				height : 50
       			}
       		}, {
       			type : 'Ti.UI.Slider',
       			events : {
       				touchend : function(e) {
       					var slider = e.source;
       
       					Ti.API.info(Number((slider.value).toFixed(0)));
       				}
       			},
       
       			properties : {
       				width : 160,
       				left : 100,
       				paddingLeft : 10,
       				min : 0,
       				max : 100,
       				value : 50
       			}
       		}]
       	}
       };
       
       var listView = Ti.UI.createListView({
       	top : 0,
       	templates : templates,
       	defaultItemTemplate : 'slider'
       });
       
       var sections = [];
       var section = Ti.UI.createListSection();
       var items = [];
       sections.push(section);
       
       for (var i = 0; i < 10; i++) {
       	console.warn('add ' + i);
       	items.push({
       		template : 'slider',
       		bindID : '' + i
       	});
       }
       
       section.appendItems(items);
       
       listView.sections = sections;
       
       win.add(listView);
       
       win.open();
       
       
       
       
    Thanks.

JSON Source