Introducing the Dialog Classes

To use the base Dialog class you create a new instance and set the title and layout, using the setTitle and setContentView methods as shown in Listing 5-27.

LISTING 5-27: Creating a new dialog using the Dialog class

Dialog d = new Dialog(MyActivity.this);

// Have the new window tint and blur the window it // obscures.

Window window = d.getWindow();

window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,

Chapter 5 Test

My number is 555-5555 and my website Is hello d.c , email me at m; com, check out qi el rot ST.CC orlTEST.COM My number is ' ' if'and my website Is www. helloworld.com, email me at com, check out quake 1 riot TEST.COM or 1TEST.COM

Q It is pitch black.

You are likely to be eaten by a grue.

FIGURE 5-5

Available for download on Wrox.com

Available for download on Wrox.com

WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

// Set the title d.setTitle("Dialog Title");

// Inflate the layout d.setContentView(R.layout.dialog_view);

// Find the TextView used in the layout // and set its text value

TextView text = (TextView)d.findViewById(R.id.dialogTextView); text.setText("This is the text in my dialog");

Once it's configured to your liking, use theshow method to display it.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide


Post a comment