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.
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();
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();
Coordinate of the view about which to pivot an animation.
Used on iOS only. For Android, use Titanium.UI.Animation.anchorPoint.
Anchor point is specified as a fraction of the view's size. For example, {0, 0}
is at
the view's top-left corner, {0.5, 0.5}
at its center and {1, 1}
at its bottom-right
corner.
See the "Using an anchorPoint" example in Titanium.UI.Animation for a demonstration.
Default: Center of this view.
Current position of the view during an animation.
Current position of the view during an animation.
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
.
Size of the left end cap.
See the section on backgroundLeftCap and backgroundTopCap behavior on iOS in Titanium.UI.View.
Default: 0
Size of the top end cap.
See the section on backgroundLeftCap and backgroundTopCap behavior on iOS in Titanium.UI.View.
Default: 0
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
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.
When cancelable
is set to true
and this is set to true
, the dialog is canceled when touched outside the window's bounds.
Default: false
View's clipping behavior.
Setting this to Titanium.UI.iOS.CLIP_MODE_ENABLED enforces all child views to be clipped to this views bounds. Setting this to Titanium.UI.iOS.CLIP_MODE_DISABLED allows child views to be drawn outside the bounds of this view. When set to Titanium.UI.iOS.CLIP_MODE_DEFAULT or when this property is not set, clipping behavior is inferred. See section on iOS Clipping Behavior in Titanium.UI.View.
Default: Undefined. Behaves as if set to Titanium.UI.iOS.CLIP_MODE_DEFAULT.
Base elevation of the view relative to its parent in pixels.
Requires: Android 5 and later
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.
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
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.
Location for the progress indicator.
This API can be assigned the following constants:
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.
The preview context used in the 3D-Touch feature "Peek and Pop".
Requires: iOS 9.0 and later
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 iOS9 or later and supporting 3D-Touch. It is ignored on older devices and can manually be checked using Titanium.UI.iOS.forceTouchSupported.
Background color of the wrapper view when this view is used as either Titanium.UI.ListView.pullView or Titanium.UI.TableView.headerPullView.
Default: Undefined. Results in a light grey background color on the wrapper view.
Clockwise 2D rotation of the view in degrees.
Clockwise 2D rotation of the view in degrees.
Translation values are applied to the static post layout value.
Clockwise rotation of the view in degrees (x-axis).
Clockwise rotation of the view in degrees (x-axis).
Translation values are applied to the static post layout value.
Clockwise rotation of the view in degrees (y-axis).
Clockwise rotation of the view in degrees (y-axis).
Translation values are applied to the static post layout value.
Scaling of the view in x-axis in pixels.
Scaling of the view in x-axis in pixels.
Translation values are applied to the static post layout value.
Scaling of the view in y-axis in pixels.
Scaling of the view in y-axis in pixels.
Translation values are applied to the static post layout value.
The view's tintColor. This property is applicable on iOS 7 and greater.
Requires: iOS 7.0 and later
This property is a direct correspondant of the tintColor property of UIView on iOS. If no value is specified, the tintColor of the View is inherited from its superview.
Default:
A material design visual construct that provides an instantaneous visual confirmation of touch point.
Requires: Android 5.0 and later
This is an opt-in feature available from Android Lollipop. Touch feedback is applied only if the backgroundColor is a solid color.
Default: false
Optional touch feedback ripple color. This has no effect unless touchFeedback
is true.
Requires: Android 5.0 and later
Default: Theme provided color.
A name to identify this view in activity transition.
Requires: Android 5 and later
Name should be unique in the View hierarchy.
Horizontal location of the view relative to its left position in pixels.
Horizontal location of the view relative to its left position in pixels.
Translation values are applied to the static post layout value.
Vertical location of the view relative to its top position in pixels.
Vertical location of the view relative to its top position in pixels.
Translation values are applied to the static post layout value.
Depth of the view relative to its elevation in pixels.
Requires: Android 5 and later
Translation values are applied to the static post layout value.
Type for the progress indicator.
This API can be assigned the following constants:
Default: Titanium.UI.Android.PROGRESS_INDICATOR_INDETERMINANT
Determines the color of the shadow.
Default: Undefined. Behaves as if transparent.
Determines the offset for the shadow of the view.
Default: Undefined. Behaves as if set to (0,-3)
Determines the blur radius used to create the shadow.
Default: Undefined. Behaves as if set to 3.
Adds the specified callback as an event listener for the named event.
Name of the event.
Callback function to invoke when the event is fired.
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.
A dictionary of properties to apply.
Finishes a batch update of the View's layout properties and schedules a layout pass of the view tree.
deprecated since 3.0.0
Use the <Titanium.Proxy.applyProperties> method to batch-update layout properties.
Since the layout pass scheduled is asynchronous, the rect
and size values may not be available immediately after
finishLayout
is called.
To be notified when the layout pass completes, add a listener for the postlayout event.
Fires a synthesized event to any registered listeners.
Name of the event.
A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.
Returns the matching view of a given view ID.
The ID of the view that should be returned. Use the id
property in your views to
enable it for indexing in this method.
Hides the progress indicator and stops the animation.
Animation options for Android. Since Release 5.1.0.
Overrides: Titanium.UI.View.hide
Inserts a view at the specified position in the children array.
Useful if the layout
property is set to horizontal
or vertical
.
Pass an object with the following key-value pairs:
view
(Titanium.UI.View): View to insertposition
(Number): Position in the children array to
insert the view. If omitted, inserts the view to the end of the array.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 of the event.
Callback function to remove. Must be the same function passed to addEventListener
.
Replaces a view at the specified position in the children array.
Useful if the layout
property is set to horizontal
or vertical
.
Pass an object with the following key-value pairs:
view
(Titanium.UI.View): View to insertposition
(Number): Position in the children array of
the view elment to replace.Sets the value of the anchorPoint property.
New value for the property.
Sets the value of the backgroundLeftCap property.
New value for the property.
Sets the value of the backgroundTopCap property.
New value for the property.
Sets the value of the bubbleParent property.
New value for the property.
Sets the value of the cancelable property.
New value for the property.
Sets the value of the canceledOnTouchOutside property.
New value for the property.
Sets the value of the clipMode property.
New value for the property.
Sets the value of the elevation property.
New value for the property.
Sets the value of the hiddenBehavior property.
New value for the property.
Sets the value of the lifecycleContainer property.
New value for the property.
Sets the value of the location property.
New value for the property.
Sets the value of the message property.
New value for the property.
Sets the value of the messageid property.
New value for the property.
Sets the value of the previewContext property.
New value for the property.
Sets the value of the pullBackgroundColor property.
New value for the property.
Sets the value of the rotation property.
New value for the property.
Sets the value of the rotationX property.
New value for the property.
Sets the value of the rotationY property.
New value for the property.
Sets the value of the scaleX property.
New value for the property.
Sets the value of the scaleY property.
New value for the property.
Sets the value of the tintColor property.
New value for the property.
Sets the value of the touchFeedback property.
New value for the property.
Sets the value of the touchFeedbackColor property.
New value for the property.
Sets the value of the transitionName property.
New value for the property.
Sets the value of the translationX property.
New value for the property.
Sets the value of the translationY property.
New value for the property.
Sets the value of the translationZ property.
New value for the property.
Sets the value of the viewShadowColor property.
New value for the property.
Sets the value of the viewShadowOffset property.
New value for the property.
Sets the value of the viewShadowRadius property.
New value for the property.
Shows the progress indicator and starts the animation.
Animation options for Android. Since Release 5.1.0.
Overrides: Titanium.UI.View.show
Starts a batch update of this view's layout properties.
deprecated since 3.0.0
Use the <Titanium.Proxy.applyProperties> method to batch-update layout properties.
To prevent a layout pass each time a property is modified, call startLayout
before
changing any properties that may change this view's layout. This initiates a batch update
mode where layout changes are deferred.
Call finishLayout to end batch update mode and trigger a layout pass. For example:
view.startLayout();
view.top = 50;
view.left = 50;
view.finishLayout();
Note that any property changes made during the batch update may be deferred until
finishLayout
is called. This may vary somewhat by platform. For example, changing the
text of a label may trigger a layout pass. In iOS, updating the label text is
deferred.
See also: updateLayout, finishLayout, postlayout event.
Performs a batch update of all supplied layout properties and schedules a layout pass after they have been updated.
deprecated since 3.0.0
Use the <Titanium.Proxy.applyProperties> method to batch-update layout properties.
This is another way to perform a batch update. The updateLayout
method is called with a
dictionary of layout properties to perform the batch update. For example:
view.updateLayout({top:50, left:50});
This is equivalent to the following:
view.startLayout();
view.top = 50;
view.left = 50;
view.finishLayout();
See also: startLayout, finishLayout, postlayout event.
Layout properties to be updated.
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.
Source object that fired the event.
Name of the event fired.
True if the event will try to bubble up if possible.
Set to true to stop the event from bubbling.
Fired when the device detects a pinch gesture.
A pinch is a touch and expand or contract with two fingers. The event occurs continuously until a finger is lifted again.
The scale factor relative to the points of the two touches in screen coordinates.
The velocity of the pinch in scale factor per second.
Source object that fired the event.
Name of the event fired.
True if the event will try to bubble up if possible.
Set to true to stop the event from bubbling.