本文实例讲述了Android设置个性化Dialog小图标的方法。分享给大家供大家参考,具体如下:
设置个性化Dialog小图标,主要代码如下:
@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) 之前调用:
requestWindowFeature(Window.FEATURE_LEFT_ICON);
2、设置小图标
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);
希望本文所述对大家Android程序设计有所帮助。