1

我写了一个像 progressdialog 这样的动画。单击按钮时,我想停止并隐藏动画。这是我的代码。

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    img = (ImageView)findViewById(R.id.imageView1);

    startButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
             img.setBackgroundResource(R.drawable.animitems);
             myAnim = (AnimationDrawable)img.getBackground();
             if(videoView.isPlaying()){
                 videoView.pause();
                 myAnim.stop();
                 myAnim.setVisible(false, true);
                 startButton.setBackgroundResource(R.drawable.andplaybtn);
             }else{
                 startButton.setBackgroundResource(R.drawable.andstopbtn);
                 myAnim.start();
                 videoView.start();
             }
        }
    });

您会看到我使用了 DrawableAnimation 类。但是我不能在开始时隐藏动画。这个怎么做?感谢您的帮助。

4

0 回答 0