I want to customize a dialog in Android. I know how to set the title for dialog:
dialog.setTitle("O message");
Now I want to set the icon in front of the title. How can I achieve this?
Dialog dialog;
dialog = new Dialog(this);
dialog.setContentView(R.layout.layouterror22);
dialog.setTitle("O message");
You can add an icon with the following code:
Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.your_icon);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Dialog Title");
dialog.show();
See "Icons in custom dialogs android".
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