Titanium.UI.Android.ProgressIndicator
A progress dialog or a horizontal progress bar in the title of the window.
| Android |
|---|
![]() |
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.
NOTE: Titanium.UI.Android.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 for more details.
Calling Titanium.UI.Android.ProgressIndicator.show displays the indicator, and calling Titanium.UI.Android.ProgressIndicator.hide removes it.
Extends: Titanium.UI.View · Since: 3.0.0 · Platforms: android
Properties #
accessibilityDisableLongPress#
Type: Boolean
Boolean value to remove the long press notification for the device's accessibility service.
Will disable the "double tap and hold for long press" message when selecting an item.
apiName#
Type: String
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.
bubbleParent#
Type: Boolean
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.
cancelable#
Type: Boolean
When true allows the user to cancel the progress dialog by pressing the BACK button.
canceledOnTouchOutside#
Type: Boolean
When cancelable is set to true and this is set to true, the dialog is canceled when touched outside the window's bounds.
elevation#
Type: Number
Base elevation of the view relative to its parent in pixels.
The elevation of a view determines the appearance of its shadow.
Higher elevations produce larger and softer shadows.
Note: The elevation property only works on Titanium.UI.View objects.
Many Android components have a default elevation that cannot be modified.
For more information, see
Google design guidelines: Elevation and shadows.
filterTouchesWhenObscured#
Type: Boolean
Discards touch related events if another app's system overlay covers the view.
This is a security feature to protect an app from "tapjacking", where a malicious app can use a
system overlay to intercept touch events in your app or to trick the end-user to tap on UI
in your app intended for the overlay.
Setting this property to true causes touch related events (including "click") to not be fired
if a system overlay overlaps the view.
hiddenBehavior#
Type: Number
Sets the behavior when hiding an object to release or keep the free space
If setting hiddenBehavior to Titanium.UI.HIDDEN_BEHAVIOR_GONE it will automatically release the space the view occupied.
For example: in a vertical layout the views below the object will move up when you hide
an object with hiddenBehavior:Titanium.UI.HIDDEN_BEHAVIOR_GONE.
- Titanium.UI.HIDDEN_BEHAVIOR_INVISIBLE. Keeps the space and just hides the object (default).
- Titanium.UI.HIDDEN_BEHAVIOR_GONE. Releases the space and hides the object.
Defaults to Titanium.UI.HIDDEN_BEHAVIOR_INVISIBLE.
horizontalMotionEffect#
Type: MinMaxOptions
Adds a horizontal parallax effect to the view
Note that the parallax effect only happens by tilting the device so results can not be seen on Simulator.
To clear all motion effects, use the Titanium.UI.clearMotionEffects method.
id#
Type: String
View's identifier.
The id property of the Ti.UI.View represents the view's identifier. The identifier string does
not have to be unique. You can use this property with Titanium.UI.View.getViewById method.
keepHardwareMode#
Type: Boolean
A value indicating the render mode of the View
Set to true to keep hardware mode when using a border and transparent backgrounds.
lifecycleContainer#
Type: Titanium.UI.Window, Titanium.UI.TabGroup
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks
will also be called on the proxy. Proxies that require the activity lifecycle will need this property set
to the appropriate containing Window or TabGroup.
messageid#
Type: String
Key identifying a string in the locale file to use for the message text.
Only one of message or messageid should be specified.
previewContext#
Type: Titanium.UI.iOS.PreviewContext
The preview context used in the 3D-Touch feature "Peek and Pop".
Preview context to present the "Peek and Pop" of a view. Use an configured instance
of Titanium.UI.iOS.PreviewContext here.
Note: This property can only be used on devices running iOS 9 or later and supporting 3D-Touch.
It is ignored on older devices and can manually be checked using Titanium.UI.iOS.forceTouchSupported.
rotation#
Type: Number
Clockwise 2D rotation of the view in degrees.
Translation values are applied to the static post layout value.
rotationX#
Type: Number
Clockwise rotation of the view in degrees (x-axis).
Translation values are applied to the static post layout value.
rotationY#
Type: Number
Clockwise rotation of the view in degrees (y-axis).
Translation values are applied to the static post layout value.
scaleX#
Type: Number
Scaling of the view in x-axis in pixels.
Translation values are applied to the static post layout value.
scaleY#
Type: Number
Scaling of the view in y-axis in pixels.
Translation values are applied to the static post layout value.
tooltip#
Type: String
The default text to display in the control's tooltip.
Assigning a value to this property causes the tool tip to be displayed for the view.
Setting the property to null cancels the display of the tool tip for the view.
Note: This property is only used for apps targeting macOS Catalyst.
touchFeedback#
Type: Boolean
A material design visual construct that provides an instantaneous visual confirmation of touch point.
Touch feedback is only applied to a view's background. It is never applied to the view's foreground content
such as a Titanium.UI.ImageView's image.
For Titanium versions older than 9.1.0, touch feedback only works if you set the
Titanium.UI.View.backgroundColor property to a non-transparent color.
touchFeedbackColor#
Type: String
Optional touch feedback ripple color. This has no effect unless touchFeedback is true.
Defaults to provided theme color.
transitionName#
Type: String
A name to identify this view in activity transition.
Name should be unique in the View hierarchy.
translationX#
Type: Number
Horizontal location of the view relative to its left position in pixels.
Translation values are applied to the static post layout value.
translationY#
Type: Number
Vertical location of the view relative to its top position in pixels.
Translation values are applied to the static post layout value.
translationZ#
Type: Number
Depth of the view relative to its elevation in pixels.
Translation values are applied to the static post layout value.
verticalMotionEffect#
Type: MinMaxOptions
Adds a vertical parallax effect to the view
Note that the parallax effect only happens by tilting the device so results can not be seen on Simulator.
To clear all motion effects, use the Titanium.UI.clearMotionEffects method.
Methods #
addEventListener #
Adds the specified callback as an event listener for the named event.
| Name | Type | Summary | Optional |
|---|---|---|---|
name | String | Name of the event. | No |
callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. | No |
applyProperties #
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.
| Name | Type | Summary | Optional |
|---|---|---|---|
props | Dictionary | A dictionary of properties to apply. | No |
clearMotionEffects #
Removes all previously added motion effects.
Use this method together with Titanium.UI.horizontalMotionEffect and Titanium.UI.verticalMotionEffect.
fireEvent #
Fires a synthesized event to any registered listeners.
| Name | Type | Summary | Optional |
|---|---|---|---|
name | String | Name of the event. | No |
event | Dictionary | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. | Yes |
getViewById #
Returns the matching view of a given view ID.
| Name | Type | Summary | Optional |
|---|---|---|---|
id | String | The ID of the view that should be returned. Use the id property in your views toenable it for indexing in this method. | No |
Returns: Titanium.UI.View
hide #
Hides the progress indicator and stops the animation.
insertAt #
Inserts a view at the specified position in the children array.
Useful if the layout property is set to horizontal or vertical.
| Name | Type | Summary | Optional |
|---|---|---|---|
params | ViewPositionOptions | Pass an object that specifies the view to insert and optionally at which position (defaults to end) | No |
removeEventListener #
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);
| Name | Type | Summary | Optional |
|---|---|---|---|
name | String | Name of the event. | No |
callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to addEventListener. | No |
replaceAt #
Replaces a view at the specified position in the children array.
Useful if the layout property is set to horizontal or vertical.
| Name | Type | Summary | Optional |
|---|---|---|---|
params | ViewPositionOptions | Pass an object with the view to insert and the position of the view to replace. In this case the position property is required. | No |
show #
Shows the progress indicator and starts the animation.
Events #
cancel #
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.
rotate #
Fired when the device detects a two finger rotation.
This event is fired when doing a two finger rotation and returning the angle.
The event occurs continuously until a finger is lifted again.
| Name | Type | Summary |
|---|---|---|
rotate | Number | Rotation in degrees. |
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>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();