Home > Android > Using Activities as Dialogs

Using Activities as Dialogs


Dialogs offer a simple and lightweight technology for displaying screens, but there will be times when you need more control over the content and life cycle of your Dialog box.
The solution is to implement it as a full Activity. By creating an Activity, you lose the lightweight nature of the Dialog class, but you gain the ability to implement any screen you want and full access to the Activity life-cycle event handlers.
So, when is an Activity a Dialog? The easiest way to make an Activity look like a Dialog is to apply the android:style/Theme.Dialog theme when you add it to your manifiest, as shown in the following XML snippet:

<activity android:name=”ActivityName”

android:theme=”@android:style/Theme.Dialog”>
</activity>
This will cause your Activity to behave like a Dialog, floating on top, and partially obscursing, the the Activity beneath it.
Source: Page 147, Professional Android Application Development Ebook
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: