tags:

views:

41

answers:

2

Hi all!

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.

Thanks, John

A: 

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();
Dave Webb
+1  A: 

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

Thorstenvv