用Dialog 做自定义动画,加播放监听

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。

 

posted @ 2014-09-03 10:47  n1rAy  阅读(601)  评论(0编辑  收藏  举报