No icon for warning dialog

even if I don't set the .setIcon(android.R.drawable.ic_dialog_alert) icon .setIcon(android.R.drawable.ic_dialog_alert) for the dialog box, it shows the info icon.

How to completely remove an icon from a 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, all .. I completely remove the .setIcon line from the dialog box. I forgot to remove it when I paste the code here. Even I delete that I still see the icon as an information icon.

+4
source share
4 answers
 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(); 
+5
source

try it

 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(); 
+4
source

Set resId to 0 in setIcon(int resId) your AlertDialog.Builder object.

+1
source

post a comment or remove this line from your setIcon code (android.R.drawable.i)

 new AlertDialog.Builder(MyActivity.this) // .setIcon(android.R.drawable.i) .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(); 
0
source

All Articles