# Titanium.UI.Android.ProgressIndicator

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

- Source: https://titaniumsdk.com/docs/sdk/13.3.0/Titanium.UI.Android.ProgressIndicator
- Titanium SDK version: 13.3.0
- Kind: view
- Platforms: Android
- Since: Titanium SDK 3.0.0
- Extends: Titanium.UI.View
- Inheritance: Titanium.UI.View > Titanium.Proxy

| Android |
| ------- |
| ![Android](./progressindicator_android.png) |

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](https://titaniumsdk.com/docs/sdk/Titanium.UI.Android.md#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](https://titaniumsdk.com/docs/sdk/Titanium.UI.Android.md#PROGRESS_INDICATOR_DIALOG),
[Titanium.UI.Android.PROGRESS_INDICATOR_STATUS_BAR](https://titaniumsdk.com/docs/sdk/Titanium.UI.Android.md#PROGRESS_INDICATOR_STATUS_BAR).

**NOTE:** [Titanium.UI.Android.PROGRESS_INDICATOR_STATUS_BAR](https://titaniumsdk.com/docs/sdk/Titanium.UI.Android.md#PROGRESS_INDICATOR_STATUS_BAR) does not work anymore on devices
running Android 4.4+ since the underlying API was deprecated and removed by Google. See
[TIMOB-27312](https://jira-archive.titaniumsdk.com/TIMOB-27312) for more details.

Calling [Titanium.UI.Android.ProgressIndicator.show](https://titaniumsdk.com/docs/sdk/Titanium.UI.Android.ProgressIndicator.md#show) displays the indicator,
and calling [Titanium.UI.Android.ProgressIndicator.hide](https://titaniumsdk.com/docs/sdk/Titanium.UI.Android.ProgressIndicator.md#hide) removes it.

## Example: Simple Progress Indicator

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

``` js
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();
```

## Example: Alloy XML Markup

Previous example as an Alloy view-controller.

index.xml:
``` 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:
``` 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();
```

## Properties

### cancelable

- Type: Boolean
- Platforms: Android

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

### canceledOnTouchOutside

- Type: Boolean
- Platforms: Android
- Since: Titanium SDK 3.6.0
- Default: `false`

When `cancelable` is set to `true` and this is set to `true`, the dialog is canceled when touched outside the window's bounds.

### location

- Type: Number
- Platforms: Android
- Default: `<Titanium.UI.Android.PROGRESS_INDICATOR_DIALOG>`

Location for the progress indicator.

Accepts: `Titanium.UI.Android.PROGRESS_INDICATOR_DIALOG`, `Titanium.UI.Android.PROGRESS_INDICATOR_STATUS_BAR`

### max

- Type: Number
- Platforms: Android

Maximum value of the progress bar.

### message

- Type: String
- Platforms: Android

Message text.

### messageid

- Type: String
- Platforms: Android

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

Only one of `message` or `messageid` should be specified.

### min

- Type: Number
- Platforms: Android

Minimum value of the progress bar.

### type

- Type: Number
- Platforms: Android
- Default: `<Titanium.UI.Android.PROGRESS_INDICATOR_INDETERMINANT>`

Type for the progress indicator.

Accepts: `Titanium.UI.Android.PROGRESS_INDICATOR_DETERMINANT`, `Titanium.UI.Android.PROGRESS_INDICATOR_INDETERMINANT`

## Methods

### hide

- Platforms: Android

Hides the progress indicator and stops the animation.

### show

- Platforms: Android

Shows the progress indicator and starts the animation.

## Events

### cancel

- Platforms: Android

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.

## Inherited members

30 members are inherited. Each is documented on the type that declares it.

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/13.3.0/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `lifecycleContainer`, `removeEventListener`
- [Titanium.UI.View](https://titaniumsdk.com/docs/sdk/13.3.0/Titanium.UI.View.md): `accessibilityDisableLongPress`, `elevation`, `filterTouchesWhenObscured`, `getViewById`, `hiddenBehavior`, `id`, `insertAt`, `keepHardwareMode`, `replaceAt`, `rotate`, `rotation`, `rotationX`, `rotationY`, `scaleX`, `scaleY`, `stopAnimation`, `tooltip`, `touchFeedback`, `touchFeedbackColor`, `transitionName`, `translationX`, `translationY`, `translationZ`

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

