even if I don't set icon .setIcon(android.R.drawable.ic_dialog_alert)
for dialog box, it is showing info icon.
How can I completely remove the icon from dialog box?
new AlertDialog.Builder(MyActivity.this)
.setTitle(R.string.success_title)
.setMessage(R.string.success_msg)
.setNeutralButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
try {
dlg.dismiss();
} catch (Exception e) {
}
}
}).show();
Edited: Sorry everyone.. I completely remove .setIcon line from the dialog box. I forget to remove it when I paste the code here. Even I remove that I still can see the icon as information icon.
You can add an icon with the following code: Dialog dialog = new Dialog(context); dialog. requestWindowFeature(Window. FEATURE_LEFT_ICON); dialog.
AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .
You can do it using showGeneralDialog and put dismissible property to false , using this will ensure you that you are the only one who is handling pop up, like in your any action buttons in dialog.
Add custom_layout. xml in that activity in which you want to show custom alert dialog here it is added in MainActivity.
new AlertDialog.Builder(MyActivity.this)
//.setIcon(android.R.drawable.i) /// put comment on this line
.setTitle(R.string.success_title)
.setMessage(R.string.success_msg)
.setNeutralButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
try
{
dlg.dismiss();
} catch (Exception e) {
}
}
}).show();
Try This
new AlertDialog.Builder(MainActivity.this)
.setIcon(null)
.setTitle("Naeem").setMessage("Shahzad").setNeutralButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
try {
dlg.dismiss();
} catch (Exception e) {
}
}
}).show();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With