Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_LEFT_ICON); // See assets/res/any/layout/dialog_activity.xml for this // view layout definition, which is being set here as // the content of our screen. setContentView(R.layout.dialog_activity); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert); }
1、申请设置个性化小图标,需在 setContentView(R.layout.dialog_activity) 之前调用。
Java 代码
requestWindowFeature(Window.FEATURE_LEFT_ICON);
requestWindowFeature(Window.FEATURE_LEFT_ICON);
2、设置小图标
Java 代码
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
android.R.drawable.ic_dialog_alert);