Here is a trick to use slider as progressbar described below.
|
CODE BLOCK :
|
//Define current window var currentWin = Ti.UI.currentWindow; //Define a button to strat the progress var stratBtn = Ti.UI.createButton({ width : 200, height : 50, title : 'Strat Progress', top : 300 }); //Button added to window currentWin.add(stratBtn); //Define a slider var sliderAsProgressbar = Titanium.UI.createSlider({ width : 300, min : 0, // Minimum value dispayed on the bar max : 100 // Maximum value dispayed on the bar }); //Set the thumb image with any transparent image sliderAsProgressbar.thumbImage = 'transparentImage.png'; //Asign initial value to the bar sliderAsProgressbar.value = 0; //Disable slider for touch effect sliderAsProgressbar.touchEnabled = false; //Bar added to window currentWin.add(sliderAsProgressbar); //Event to start progress stratBtn.addEventListener('click', function(){ //Asign initial value to the bar sliderAsProgressbar.value = 0; var cahangedVal = 0, progressInterval; //Check the progress interval if (progressInterval) { clearInterval(progressInterval); } //Do the progress stuff progressInterval= setInterval(function() { //Condition to check max value if (val >= 101) { //Stop the progressing clearInterval(progressInterval); //Asign initial value to the bar sliderAsProgressbar.value = 0; return; } //Change the bar value to show progress sliderAsProgressbar.value = cahangedVal ; cahangedVal++; }, 1000); }); NOTE : Tested in Android, IOS, Mobileweb.