2016-07-01 14 views
0

TextSwitcherとImageSwitcherオブジェクトを使ったアンドロイドスタジオプロジェクトが既に設定されていて、完璧に(同時に)動作しています。 まず、TextSwitcherのアニメーションを先に行い、ImageSwitcherのアニメーションを2番目に(TextSwitcherアニメーションが終了した後に)したい。 AnimationListenerをTextSwitcherに追加し、AnimationListenerの 'onAnimationEnd'メソッド内のImageSwitcherのイメージを変更しようとしましたが、動作しませんでした。TextSwitcherとImageSwitcherのアニメーションの連鎖

誰にもアイデアはありますか? ご協力いただければ幸いです!

EDIT: は、アニメーションのリスナーはここで、仕事を得るためにうまく管理は、コードの抜粋です:

private void loadPosts() { 
     Post post = posts.get(currentPost); 
     //.. 
     Animation outAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out); 
     outAnimation.setAnimationListener(new NextPostAnimation(post)); 
     textSwitcher.setOutAnimation(outAnimation); 
     textSwitcher.setText("some text"); 

    } 

    private class NextPostAnimation implements Animation.AnimationListener { 
     Post post; 

     NextPostAnimation (Post post) { 
      super(); 
      this.post = post; 
     } 
     @Override 
     public void onAnimationStart(Animation animation) { 
      // TODO Auto-generated method stub 
     } 

     @Override 
     public void onAnimationRepeat(Animation animation) { 
      // TODO Auto-generated method stub 

     } 

     @Override 
     public void onAnimationEnd(Animation animation) { 
      imageSwitcher1.setImageDrawable(new BitmapDrawable(getResources(), post.image1)); 
     } 
    } 

はチェーンオブジェクトのアニメーションへの短い方法はありますか?

+0

コンテキストを提供するために、あなたのコードを含めることを検討してください。参照:http://stackoverflow.com/help/mcve – SoAwesomeMan

答えて

0

最初のアニメーションコールバックに2番目のアニメーションを配置する必要があります。 以下は作業コードです。

$(function(){ 
 
\t $('.textSwitcher').show(1000, function(){ 
 
    \t $('.imageSwitcher').show(1000); 
 
    }); 
 
})
.textSwitcher, .imageSwitcher { 
 
    width: 100px; 
 
    height: 100px; 
 
    display: none; 
 
} 
 
.textSwitcher { 
 
    background: red; 
 
} 
 

 
.imageSwitcher { 
 
    background: blue;  
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="textSwitcher"></div> 
 
<div class="imageSwitcher"></div>

関連する問題