Titanium.UI.AlertDialog

Object of Titanium.UI.
Platform Since
Android 0.8
iPhone 0.8
iPad 0.8
Mobile Web 0.8

Summary

The Alert Dialog is created by Titanium.UI.createAlertDialog and allows you to show a modal application dialog.

Description

the global method alert is aliased to this object and can be invoked with a single message. For example:

alert("this is a message");

Note: you should be careful not to call alert more than once while a pending alert is visible.

On iOS 4, alert dialogs will automatically be cancelled upon application suspend.

Code Examples

Simple Alert Dialog

In this example, we show a simple alert dialog.

var alertDialog = Titanium.UI.createAlertDialog({
    title: 'Hello',
    message: 'You got mail',
    buttonNames: ['OK','Doh!']
});
alertDialog.show();

Methods

Name Summary
addEventListener

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

fireEvent

Fires a synthesized event to any registered listeners.

hide

hides the alert dialog and unblocks the background view

removeEventListener

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

show

shows the alert dialog and blocks the background view like a modal window

Properties

Name Type Summary
androidView Titanium.UI.View

Titanium view that should be loaded inside the alert dialog (Android, iPhone, iPad only.)

buttonNames Array<Object>

array of button names as strings

cancel Number

an index to indicate which button should be the cancel button

message String

the message of the dialog

messageid String

the key in the locale file to use for the message property

ok String

Text for the OK button. Useful for when you only want one button and therefore don't want to use the buttonNames property. If you do use buttonNames, this property will be ignored. (Android, iPhone, iPad only.)

okid String

the key in the locale file to use for the ok property. Note that if you use the buttonNames property to set the button titles, this will be ignored. (Android, iPhone, iPad only.)

title String

the title of the dialog

titleid String

the key in the locale file to use for the title property (Android, iPhone, iPad only.)

Events

Name Summary
click

fired when a button in the dialog is clicked