4

This code will display the dialog box with "Hello World" but I want to display an image like : enter image description here also in the same dialog box.

can anyone help me?

private void showDialog(String message)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Hello World");
    builder.setCancelable(false);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
    {
        public void onClick(DialogInterface dialog, int id)
        {
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}
1
  • Thanks Nanne, I just put a suggestion regarding code.
    – TeaCupApp
    May 23, 2011 at 12:03

3 Answers 3

4

Here is the link which will get you to the tutorial about how to do this...

http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

Enjoy!

Advice:

Search this website you can find most of basic fundamentals http://developer.android.com

Suggestion:

HIT four time space bar before writing any code...it will attract more people to answer your question as it will look well written

Happy Coding!

0
2

Use CustomDialog instead of the default one.

Checkout this for customDialog: http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application

Hope this will solve your issue.

0
private void showDialog(String message)
{
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setMessage("Hello World");
      builder.setIcon(R.drawable.hello);
      builder.setCancelable(false);
      builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
      {
          public void onClick(DialogInterface dialog, int id)
          {
               dialog.dismiss();
           }
      });
            AlertDialog alert = builder.create();
            alert.show();
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.