0

好吧,我是这个词的新人,我试图延迟充气,因为当你按下一个按钮时,其他按钮中的动画就会发生并且充气也会发生。

但是你看不到动画,因为 inflate 来得很快,所以我想将 inflate 延迟 2000 毫秒,这样你就可以先看到动画,然后再看到 inflate 中的信息。

我使用相同的按钮来调用动画和充气。

这是我的代码:

 case R.id.btnsalud:

    //This is the code for animations   

        //This is the loader for all the animations that is used for the button
        {final Animation animBounceForSalud = AnimationUtils.loadAnimation(this, R.anim.bounce);
        final Animation animBounceForSalud1 = AnimationUtils.loadAnimation(this, R.anim.bounce1);
        //This object is the objects (buttons) whom is applied the animation
        final Button animSalud = (Button)findViewById(R.id.btnobra);
        final Button animSalud1 = (Button)findViewById(R.id.btnprotesta);
        //This object (button) is the one which applies the animation to the other buttons
        Button btnBounceSalud = (Button)findViewById(R.id.btnsalud);      
    animSalud.startAnimation(animBounceForSalud);
    animSalud1.startAnimation(animBounceForSalud1);
    animSalud.setVisibility(500);
    animSalud1.setVisibility(500);}



    //This is the code for inflate  
    //Check if the Layout already exists
    LinearLayout hiddenLayout1 = (LinearLayout)findViewById(R.id.hiddenLayout);
    if((hiddenLayout1 == null)){
        //Right here is where you can defined in which layout is going to 
        //inflate the hidden layout
        LinearLayout myLayout = (LinearLayout)findViewById(R.id.inflateposition0);
        View hiddenInfo = getLayoutInflater().inflate(R.layout.salud, myLayout, false);
        myLayout.addView(hiddenInfo);

    }

    break;

任何答案将不胜感激:D

4

2 回答 2

0

您应该为动画设置一个监听器(http://developer.android.com/reference/android/view/animation/Animation.html#setAnimationListener(android.view.animation.Animation.AnimationListener))并且只在侦听器报告动画已完成。

于 2013-01-30T18:16:15.517 回答
0

您可以在动画定义中设置持续时间参数来确定动画应该有多长。在 Java 中有 setDuration(time) 方法,在 XML 中定义动画有 android:duration 属性。 http://developer.android.com/guide/topics/resources/animation-resource.html

于 2013-01-30T19:49:21.470 回答