个性化Dialog小图标

个性化Dialog小图标,主要代码如下:
@
Java代码  
  1. Override  
  2.     protected void onCreate(Bundle savedInstanceState) {  
  3.         // Be sure to call the super class.  
  4.         super.onCreate(savedInstanceState);  
  5.           
  6.         requestWindowFeature(Window.FEATURE_LEFT_ICON);  
  7.           
  8.         // See assets/res/any/layout/dialog_activity.xml for this  
  9.         // view layout definition, which is being set here as  
  10.         // the content of our screen.  
  11.         setContentView(R.layout.dialog_activity);  
  12.           
  13.         getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,   
  14.                 android.R.drawable.ic_dialog_alert);  
  15.     }  

1、申请设置个性化小图标,需在 setContentView(R.layout.dialog_activity) 之前调用。
Java代码  
  1. requestWindowFeature(Window.FEATURE_LEFT_ICON);  


2、设置小图标

Java代码  
  1. getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,   
  2.                 android.R.drawable.ic_dialog_alert); 

你可能感兴趣的:(个性化Dialog小图标)