开发者

How to display an image in Dialog Box

This code will display the dialog box with "Hello World" but I want to display an image like :

How to display an image in Dialog Box

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");
开发者_Python百科    builder.setCancelable(false);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
    {
        public void onClick(DialogInterface dialog, int id)
        {
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}


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!


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.


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();
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜