final Dialog customDialog = new Dialog(this); customDialog.setTitle(R.string.attention); customDialog.setContentView(R.layout.connectionview); ImageView image = (ImageView)customDialog.findViewById(R.id.anim); image.setBackgroundResource(R.drawable.connection); customDialog.setOnShowListener(new DialogInterface.OnShowListener(){ public void onShow(android.content.DialogInterface dialog){ ImageView image =(ImageView)customDialog.findViewById(R.id.anim); AnimationDrawable ad = (AnimationDrawable)image.getBackground(); if(ad != null) { ad.start(); } } }); customDialog.show(); 这里利用的onShowListener,注意这个接口需要高版本的SDK。