修改钛合金滑块

时间:2014-05-21 17:13:05

标签: titanium titanium-mobile

默认的钛金属滑块只允许你有一个引脚。

如何修改它,以便它接受一系列值。如年龄范围?

干杯。

更新(安装模块后):

// Double Slider example

var tidoubleslider = require('com.semanticpress.tidoubleslider');

var dSlider = tidoubleslider.createSlider({
    top: 40,
    height: 50,
    width: 280,
    leftTrackImage:'left2.png',
    highlightedLeftTrackImage:'highlightedLeft2.png',
    disabledLeftTrackImage:'disabledLeft2.png',
    centerTrackImage:'center2.png',
    highlightedCenterTrackImage:'highlightedCenter2.png',
    disabledCenterTrackImage:'disabledCenter2.png',
    rightTrackImage:'right2.png',
    highlightedRightTrackImage:'highlightedRight2.png',
    disabledRightTrackImage:'disabledRight2.png',
    leftThumbImage:'thumb.png',
    highlightedLeftThumbImage:'highlightedThumb.png',
    disabledLeftThumbImage:'disabledThumb.png',
    rightThumbImage:'thumb.png',
    highlightedRightThumbImage:'highlightedThumb.png',
    disabledRightThumbImage:'disabledThumb.png',
    min:0,
    max:50,
    leftValue:25,
    rightValue:50,
    enabled: true
});
$.ageSliderView.add(dSlider);

var leftLabel = Ti.UI.createLabel({
    top:30,
    left:20,
    width:100,
    height: 20,
    color:'black',
    text:dSlider.leftValue
});
$.ageSliderView.add(leftLabel);

var rightLabel = Ti.UI.createLabel({
    top:30,
    right:20,
    width:100,
    height: 20,
    color:'black',
    text:dSlider.rightValue,
    textAlign:'right'
});
$.ageSliderView.add(rightLabel);

dSlider.addEventListener('touchstart', function(e) {
    if (typeof e.value !== 'undefined') {
        if (e.thumbIndex === 0) {
            leftLabel.text = e.value.toFixed(1);
            leftLabel.color = 'red';
        }
        else {
            rightLabel.text = e.value.toFixed(1);
            rightLabel.color = 'red';
        }
    }
    else {
        leftLabel.color = 'gray';
        rightLabel.color = 'gray';
    }
});

dSlider.addEventListener('change', function(e) {
    if (e.thumbIndex === 0) {
        leftLabel.text = e.value.toFixed(1);
    }
    else {
        rightLabel.text = e.value.toFixed(1);
    }
});

dSlider.addEventListener('touchend', function(e) {
    if (typeof e.value !== 'undefined') {
        if (e.thumbIndex === 0) {
            leftLabel.text = e.value.toFixed(1);
            leftLabel.color = 'black';
        }
        else {
            rightLabel.text = e.value.toFixed(1);
            rightLabel.color = 'black';
        }
    }
    else {
        leftLabel.color = 'black';
        rightLabel.color = 'black';
    }
});

滑块未出现在屏幕上。我想这是因为滑块图像丢失了?

1 个答案:

答案 0 :(得分:1)

这里你去。滑块有钛的raning选项

https://github.com/tzmartin/Ti-Double-Slider/tree/master/dist

由于