Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't this AlertDialog.Builder.setIcon show the ic_menu_info icon?

The ic_menu_info icon is properly displayed in the xml menu item that calls it but not in this AlertDialog.

new AlertDialog.Builder(this).setMessage(menuInfo).setNeutralButton("OK",
 new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface d, int i) {
   // do nothing – it will close on its own
  }
 })
 .setIcon(R.drawable.ic_menu_info).show();
 ...
like image 321
jacknad Avatar asked Sep 23 '10 18:09

jacknad


People also ask

How do I show AlertDialog in Kotlin?

To set the action on alert dialog call the setPositiveButton(), setNeutralButton() and setNegativeButton() methods for positive, neutral and negative action respectively. The show() method of AlertDialog. Builder is used to display the alert dialog.

How many buttons can an AlertDialog display?

AlertDialog. A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout.

What's the difference between dialog and AlertDialog in Android?

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 .


1 Answers

Needed a .setTitle() since that is where the icon wants to go.


like image 88
jacknad Avatar answered Oct 19 '22 22:10

jacknad