You could use an AlertDialog
for this and construct one using its Builder
class. The example below uses the default constructor that only takes in a Context
since the dialog will inherit the proper theme from the Context you pass in, but there's also a constructor that allows you to specify a specific theme resource as the second parameter if you desire to do so.
new AlertDialog.Builder(context)
.setTitle("Delete entry")
.setMessage("Are you sure you want to delete this entry?")
// Specifying a listener allows you to take an action before dismissing the dialog.
// The dialog is automatically dismissed when a dialog button is clicked.
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Continue with delete operation
}
})
// A null listener allows the button to dismiss the dialog and take no further action.
.setNegativeButton(android.R.string.no, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
I took some time to check it in detail. I created an icon whose images have sizes of 16, 24, 32, 40, 48, 64, 96, 128 and 256. Then I checked which image is shown. All these were done with normal 96dpi. If using a larger DPI, the larger sizes may be used (only checked this a bit in Windows 7). The results:
Windows XP:
- Explorer views:
- Details / List: 16
- Icons: 32
- Tiles / Thumbnails: 48
- Right-click->Properties / choosing a new icon: 32
- Quickstart area: 16
- Desktop: 32
Windows 7:
- Explorer views:
- Details / List / Small symbols: 16
- All other options: 256 (resized, if necessary)
- Right-click->Properties / choosing a new icon: 32
- Pinned to taskbar: 32
- Desktop:
- Small symbols: 32
- Medium symbols: 48
- Large symbols: 256 (resized, if necessary)
- Zooming using Ctrl+Mouse wheel: 16, 32, 48, 256
Windows Runtime: (from here)
- Main tile: 150x150, 310x150 (wide version)
- Small logo: 30x30
- Badge (for lockscreen): 24x24, monochromatic
- Splashscreen: 620x300
- Store: 50x50
So the result: Windows XP uses 16, 32, 48-size icons, while Windows 7 (and presumably also Vista) also uses 256-size icons. All other intermediate icon sizes are ignored (they may be used in some area which I didn't check).
I also checked in Windows 7 what happens if icon sizes are missing:
The missing sizes are generated (obviously). With sizes of 16, 32, and 48, if one is missing, downscaling is preferred. So if we have icons with size 16 and 48, the 32 icon is created from the 48 icon. The 256 icon is only used for these if no other sizes are available! So if the icons are size 16 and 256, the other sizes are upscaled from the 16 icon!
Additionally, if the 256 icon is not there, the (possibly generated) 48 icon is used, but not resized anymore. So we have a (possibly large) empty area with the 48 icon in the middle.
Note that the default desktop icon size in XP was 32x32, while in Windows 7 it is 48x48.
As a consequence, for Windows 7 it is relatively important to have a 48 icon. Otherwise, it is upscaled from a smaller icon, which may look quite ugly.
Just a note about Windows XP compatibility: If you reuse the icon as window icon, then note that this can crash your application if you use a compressed 256 icon. The solution is to either not compress the icon or create a second version without the (compressed) 256 icon. See here for more info.
Best Answer
-------update 2015.10.17--------
The new google design gideline says:"System icons are displayed at 24dp","Icon content is limited to the 20 x 20dp live area, with 4px of trim around the perimeter".Like:
------old-------
Full asset, 32x32 dp; Optical square, 24x24 dp