David Brown
David Brown

Reputation: 4823

Pop-Up display in Android using alertdialog.builder

I am new to Android Programming. I need to display a Pop-Up message in my application which I have no clue about. I got to hear from somewhere that it can be done using alertdialog.builder, but I have no idea how to do that?

I just want to display a simple Text Message.

Can anybody please help me out regarding this with an example if possible.

Upvotes: 0

Views: 1436

Answers (2)

Thorstenvv
Thorstenvv

Reputation: 5396

If you really need a pop up that the user has to acknowledge by pressing a button, you can do something like this:

new AlertDialog.Builder(context).setMessage("message text").setPositiveButton("OK", null).setTitle("Title").show();

you can leave out setTitle if you don't need it

Upvotes: 1

David Webb
David Webb

Reputation: 193696

If you want to display a simple message you're probably better off using a Toast.

Toast.makeText(this, "Some Text", Toast.LENGTH_LONG).show();

Or, if you're doing it properly, and using a String resource:

Toast.makeText(this, getString(R.string.message_toast), Toast.LENGTH_LONG).show();

Upvotes: 2

Related Questions