Titanium.UI.Android.ProgressIndicator

> Titanium.UI.Android.ProgressIndicator

A progress dialog or a horizontal progress bar in the title of the window.

A progress indicator can be used to show the progress of an operation in the UI to let the user know that some action is taking place. It is used to indicate an ongoing activity of determinate or indeterminate length.

Use the Titanium.UI.Android.createProgressIndicator method or <ProgressIndicator> Alloy element to create a progress indicator.

A progress indicator can be either a progress dialog or a horizontal progress bar in the title of the window. The progress dialog is a modal dialog that blocks the UI. See also: Titanium.UI.Android.PROGRESS_INDICATOR_DIALOG, Titanium.UI.Android.PROGRESS_INDICATOR_STATUS_BAR.

Calling show displays the indicator, and calling hide removes it.

To display a horizontal progress bar in the title of a heavyweight window, wait for the window to open before creating the progress bar. For example, in the sample code below, for it to work in the status bar, create the progress bar inside the event listener, which waits for the open event.

Examples

Simple Progress Indicator

Click the button to show a progress indicator while some code executes and hide it on completion.

Ti.UI.backgroundColor = 'white';

var win = Ti.UI.createWindow({
  backgroundColor: 'blue'
});

var button = Ti.UI.createButton({
  title: 'Show Progress Dialog'
});

var progressIndicator = Ti.UI.Android.createProgressIndicator({
  message: 'Loading...',
  location: Ti.UI.Android.PROGRESS_INDICATOR_DIALOG,
  type: Ti.UI.Android.PROGRESS_INDICATOR_DETERMINANT,
  cancelable: true,
  min: 0,
  max: 10
});

button.addEventListener('click', function (e) {
  progressIndicator.show();
  var value = 0;
  setInterval(function(){
    if (value > 10) {
        return;
    }
    progressIndicator.value = value;
    value ++;
  }, 200);
  // do some work that takes 3 seconds
  // ie. replace the following setTimeout block with your code
  setTimeout(function(){
    progressIndicator.hide();
  }, 3000);
});

win.add(button);
win.open();

Alloy XML Markup

Previous example as an Alloy view-controller.

index.xml:

<Alloy>
    <Window backgroundColor="blue">
        <Button id="button" onClick="showIndicator">Show Progress Dialog</Button>

        <ProgressIndicator ns="Ti.UI.Android" platform="android" id="progressIndicator"
         message="Loading..." min="0" max="10" cancelable="true"
         location="Ti.UI.Android.PROGRESS_INDICATOR_DIALOG"
         type="Ti.UI.Android.PROGRESS_INDICATOR_DETERMINANT" />
    </Window>
</Alloy>

index.js:

function showIndicator(e) {
    $.progressIndicator.show();
    var value = 0;
    setInterval(function(){
        if (value > 10) {
            return;
        }
        $.progressIndicator.value = value;
        value ++;
    }, 200);
    // do some work that takes 3 seconds
    // ie. replace the following setTimeout block with your code
    setTimeout(function(){
        $.progressIndicator.hide();
    }, 3000);
}
$.index.open();

  • 3.0
Defined By

Properties

apiName : Stringreadonly

The name of the API that this proxy corresponds to.

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Button returns Ti.UI.Button.

  • 3.2
  • 3.2
  • 3.2
  • 3.2
  • 3.2
  • 3.2
Indicates if the proxy will bubble an event to its parent. ...

Indicates if the proxy will bubble an event to its parent.

Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.

Default: true

  • 3.0
  • 3.0
  • 3.0
Titanium.UI.Android.ProgressIndicator
cancelable : Boolean

When true allows the user to cancel the progress dialog by pressing the BACK button.

When true allows the user to cancel the progress dialog by pressing the BACK button.

  • 3.0
Titanium.UI.Android.ProgressIndicator
: Number
Location for the progress indicator. ...

Location for the progress indicator.

This property can be assigned the following constants:

Default: Titanium.UI.Android.PROGRESS_INDICATOR_DIALOG

  • 3.0
Titanium.UI.Android.ProgressIndicator
max : Number

Maximum value of the progress bar.

Maximum value of the progress bar.

  • 3.0
Titanium.UI.Android.ProgressIndicator
message : String

Message text.

Message text.

  • 3.0
Titanium.UI.Android.ProgressIndicator
messageid : String

Key identifying a string in the locale file to use for the message text.

Key identifying a string in the locale file to use for the message text.

Only one of message or messageid should be specified.

  • 3.0
Titanium.UI.Android.ProgressIndicator
min : Number

Minimum value of the progress bar.

Minimum value of the progress bar.

  • 3.0
Titanium.UI.Android.ProgressIndicator
: Number
Type for the progress indicator. ...
Defined By

Methods

( name, callback ) : void
Adds the specified callback as an event listener for the named event. ...

Adds the specified callback as an event listener for the named event.

Parameters

  • name : String

    Name of the event.

  • callback : Callback<Object>

    Callback function to invoke when the event is fired.

Returns

  • void
Applies the properties to the proxy. ...

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.

  • 3.0
  • 3.3
  • 3.0
  • 3.0
  • 3.0
  • 3.1

Parameters

  • props : Dictionary

    A dictionary of properties to apply.

Returns

  • void
( name, event ) : void
Fires a synthesized event to any registered listeners. ...

Fires a synthesized event to any registered listeners.

Parameters

  • name : String

    Name of the event.

  • event : Dictionary

    A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Returns

  • void
Gets the value of the apiName property. ...

Gets the value of the apiName property.

  • 3.2
  • 3.2
  • 3.2
  • 3.2
  • 3.2
  • 3.2

Returns

  • String
Gets the value of the bubbleParent property. ...

Gets the value of the bubbleParent property.

  • 3.0
  • 3.0
  • 3.0

Returns

  • Boolean
Titanium.UI.Android.ProgressIndicator
( ) : Boolean
Gets the value of the cancelable property. ...

Gets the value of the cancelable property.

  • 3.0

Returns

  • Boolean
Titanium.UI.Android.ProgressIndicator
( ) : Number
Gets the value of the location property. ...

Gets the value of the location property.

  • 3.0

Returns

  • Number
Titanium.UI.Android.ProgressIndicator
( ) : Number
Gets the value of the max property. ...

Gets the value of the max property.

  • 3.0

Returns

  • Number
Titanium.UI.Android.ProgressIndicator
( ) : String
Gets the value of the message property. ...

Gets the value of the message property.

  • 3.0

Returns

  • String
Titanium.UI.Android.ProgressIndicator
( ) : String
Gets the value of the messageid property. ...

Gets the value of the messageid property.

  • 3.0

Returns

  • String
Titanium.UI.Android.ProgressIndicator
( ) : Number
Gets the value of the min property. ...

Gets the value of the min property.

  • 3.0

Returns

  • Number
Titanium.UI.Android.ProgressIndicator
( ) : Number
Gets the value of the type property. ...

Gets the value of the type property.

  • 3.0

Returns

  • Number
Titanium.UI.Android.ProgressIndicator
( ) : void
Hides the progress indicator and stops the animation. ...

Hides the progress indicator and stops the animation.

  • 3.0

Returns

  • void
( name, callback ) : void
Removes the specified callback as an event listener for the named event. ...

Removes the specified callback as an event listener for the named event.

Multiple listeners can be registered for the same event, so the callback parameter is used to determine which listener to remove.

When adding a listener, you must save a reference to the callback function in order to remove the listener later:

var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);

To remove the listener, pass in a reference to the callback function:

window.removeEventListener('click', listener);

Parameters

  • name : String

    Name of the event.

  • callback : Callback<Object>

    Callback function to remove. Must be the same function passed to addEventListener.

Returns

  • void
( bubbleParent ) : void
Sets the value of the bubbleParent property. ...

Sets the value of the bubbleParent property.

  • 3.0
  • 3.0
  • 3.0

Parameters

  • bubbleParent : Boolean

    New value for the property.

Returns

  • void
Titanium.UI.Android.ProgressIndicator
( cancelable ) : void
Sets the value of the cancelable property. ...

Sets the value of the cancelable property.

  • 3.0

Parameters

  • cancelable : Boolean

    New value for the property.

Returns

  • void
Titanium.UI.Android.ProgressIndicator
( location ) : void
Sets the value of the location property. ...

Sets the value of the location property.

  • 3.0

Parameters

  • location : Number

    New value for the property.

Returns

  • void
Titanium.UI.Android.ProgressIndicator
( max ) : void
Sets the value of the max property. ...

Sets the value of the max property.

  • 3.0

Parameters

  • max : Number

    New value for the property.

Returns

  • void
Titanium.UI.Android.ProgressIndicator
( message ) : void
Sets the value of the message property. ...

Sets the value of the message property.

  • 3.0

Parameters

  • message : String

    New value for the property.

Returns

  • void
Titanium.UI.Android.ProgressIndicator
( messageid ) : void
Sets the value of the messageid property. ...

Sets the value of the messageid property.

  • 3.0

Parameters

  • messageid : String

    New value for the property.

Returns

  • void
Titanium.UI.Android.ProgressIndicator
( min ) : void
Sets the value of the min property. ...

Sets the value of the min property.

  • 3.0

Parameters

  • min : Number

    New value for the property.

Returns

  • void
Titanium.UI.Android.ProgressIndicator
( type ) : void
Sets the value of the type property. ...

Sets the value of the type property.

  • 3.0

Parameters

  • type : Number

    New value for the property.

Returns

  • void
Titanium.UI.Android.ProgressIndicator
( ) : void
Shows the progress indicator and starts the animation. ...

Shows the progress indicator and starts the animation.

  • 3.0

Returns

  • void
Defined By

Events

Titanium.UI.Android.ProgressIndicator
Fired when the user has canceled the progress indicator dialog. ...

Fired when the user has canceled the progress indicator dialog.

The user triggers this event by pressing the BACK button when the dialog is visible. The dialog will be hidden and this event dispatched.

  • 3.0

Properties

  • bubbles : Boolean

    True if the event will try to bubble up if possible.

    •  
    •  
    •  
  • cancelBubble : Boolean

    Set to true to stop the event from bubbling.

    •  
    •  
    •  
  • source : Object

    Source object that fired the event.

  • type : String

    Name of the event fired.