隐形匆匆不工作在Android的动画完成后, [英] Invisibility and GONE doesnt work after animation in android

查看:143
本文介绍了隐形匆匆不工作在Android的动画完成后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个code当我点击一个imagebox,另一个对象运行的动画,并通过visibility.GONE dissaper本身。但它不工作!这里是我的code:

i use this code to when i click on a imagebox, run an animation on another object and dissaper itself via visibility.GONE. but it doesnt work!! here is my code:

againbtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            //answer button on animation
            Animation anim2 = AnimationUtils.loadAnimation(MainActivity.this, R.anim.askbtnonanim);
            anim2.setFillAfter(true);
            askbtn.startAnimation(anim2);

            //gone myselft (againbtn)
            againbtn.setVisibility(View.GONE);
        }
    });

如果从这个code删除动​​画3线,一切都OK和工作,但现在没有。但为什么?它涉及到anim2.setFillAfter(真); ???我把这个,因为我的动画运行一次,不重!请大家帮我

if a delete 3 animation line from this code, everything is OK and works, but now it doesn't. but why? it's related to anim2.setFillAfter(true); ??? i put this because my animation run one time and dont reset! please help me

推荐答案

您应该实现动画监听器和onAnimationEnd(),你应该执行你的任务...下面code,希望会帮助你...

You should implement Animation Listener and in onAnimationEnd() you should perform your task... hope below code will help you...

anim2.setAnimationListener(new Animation.AnimationListener(){
    @Override
    public void onAnimationStart(Animation arg0) {
    }           

    @Override
    public void onAnimationRepeat(Animation arg0) {
    }           

    @Override
    public void onAnimationEnd(Animation arg0) {
        againbtn.setVisibility(View.GONE);  //set your button visibility here
    }


});

这篇关于隐形匆匆不工作在Android的动画完成后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆