Reputation: 75
This code will display the dialog box with "Hello World" but I want to display an image like : 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();
}
Upvotes: 4
Views: 31767
Reputation: 1
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();
}
Upvotes: 0
Reputation: 11571
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.
Upvotes: 2
Reputation: 11452
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!
Upvotes: 4