I declared a dialog activity in my Manifest as follows:
<activity android:name=".myDialog"
android:label="@string/title_dlg"
android:icon="@android:drawable/ic_dialog_alert"
android:exported="false"
android:excludeFromRecents="true"
android:theme="@android:style/Theme.Dialog">
However, only the title's text appears in the title bar and the icon appears to be ignored. Is there a way to also show the icon in the title bar?
Use this after your super.onCreate(savedInstanceState);
call:
requestWindowFeature(Window.FEATURE_LEFT_ICON);
Then, set your contentView(R.layout.youLayout);
and then use this:
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);
The order is important.
I think using below line after super
call will work
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
Keep in mind to place it before setting content view
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