var win = Titanium.UI.createWindow({ backgroundColor:"#FFF" }); var slider1 = Titanium.UI.createSlider({ height:"auto", 300, top:100, min:0, //slider最小值 (Android) max:10 //slider最大值 (Android) }); //这个标签包含了文本将改变与每一个slider1移动 var results1 = Titanium.UI.createLabel({ text:"滑动slider1", height:40, "auto", top:140 }); var slider2 = Titanium.UI.createSlider({ height:"auto", 300, bottom:40, thumbImage:"images/bar.png", //slider bar图片 highlightedThumbImage:"images/bar-over.png", rightTrackImage:"images/button.png", leftTrackImage:"images/button-over.png", min:0, max:100, value:50 }); var results2 = Titanium.UI.createLabel({ text:"滑动slider2", height:40, "auto", bottom:10 }); var PLATFORM = Titanium.Platform.osname; //在Android, 我们可以设置最大最小值 if(PLATFORM === "android"){ var slider3 = Titanium.UI.createSlider({ height:"auto", 300, top:220, min:0, max:100, minRange:25, maxRange:75, value:50 //初始值 }); var results3 = Titanium.UI.createLabel({ text:"滑动slider3 (Android)", height:40, "auto", top:260 }); } slider1.addEventListener("change", function(e){ results1.text = e.value; }); slider2.addEventListener("change", function(e){ results2.text = e.value; }); if(PLATFORM === "android"){ slider3.addEventListener("change", function(e){ results3.text = e.value; }); } win.add(slider1); win.add(results1); win.add(slider2); win.add(results2); if(PLATFORM === "android"){ win.add(slider3); win.add(results3); } win.open();