0

ボタンをアニメーション化(つまり、回転、平行移動)してから、ボタンのテキストを変更したい。残念ながら、それは常に最初にボタンのテキストを変更し、次にアニメーションを実行します。

どうすれば目標を達成できますか?

plsは私を助けます

私のコードはこのようなものです。

AnimationSet set = new AnimationSet(true);

                    Animation anim1 = new RotateAnimation(0, 360, 500, 750);
                    anim1.setDuration(3000);
                    anim1.setFillAfter(true);
                    set.addAnimation(anim1);

                    Animation anim2 = new RotateAnimation(0, 360, 1024, 824);
                    anim2.setDuration(3000);
                    anim2.setFillAfter(true);
                    set.addAnimation(anim2);

                    anim2.setStartOffset(3000);

                    first.clearAnimation();
                    set.setFillAfter(true);
                    first.startAnimation(set);      

                    numbers[0]=min + (int)(Math.random() * ((max - min) + 1));
4

2 に答える 2

0

コードはアニメーションを開始しますが、ブロックしていません。アニメーションが開始されると、プログラムは続行されます。

ハンドラーを取得して、適切なタイミングでテキスト変更イベントを投稿してみてください。

Handler mHandler=new Handler();
Runnable lRunnable =new Runnable()
{
    public void run() 
    {
    //Your change text code                       
    }
};
mHandler.postDelayed(lRunnable , 3000); // Or any other duration so you have the right effect
于 2012-09-17T13:18:58.003 に答える
0

より良い解決策は、AnimationListenerをアニメーションに追加することです。または、JBを使用している場合は、ビュープロパティアニメーターとwithEndAction()メソッドを使用します。可能であれば、古いアニメーションフレームワークは避けてください。実際にプロパティを変更するのではなく、変換を使用してビューを描画するだけです。

set.setAnimationListener(new AnimationListener() {
    public void onAnimationEnd() {
        // ...
    }

    public void onAnimationStart() {
    }

    public void onAnimationRepeat() {
    }
}

ただし、ビュープロパティアニメーションを使用できる場合は、それらをお勧めします。彼らは一緒に働く方がはるかに良いです。

于 2012-09-18T08:29:22.347 に答える