2017-06-30 8 views
-4

私はAndroid Studioが初めてです。ボタンのアニメーションと第2アクティビティのオープニングの間に遅延を入れてアニメーションを実行し、スプラッシュアクティビティを開きます。1つの方法の2つの機能の間の遅延

btn.setOnClickListener(new View.OnClickListener(){ 
     public void onClick(View arg0){ 
      Animation anim4 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.splash_anim); 
      btn.startAnimation(anim4); 

      startActivity(new Intent(MainActivity.this, splashActivity.class)); 
     } 
    }); 
+0

、この時間を増やすことができますがスリープ状態にしたいですか? –

+0

次のようにハンドラを使うことができます:Handler handler = new Handler(); handler.postDelayed(新しいRunnableを(){ @Override公共ボイドラン(){ startRecord(); mp.stop(); mp.release();} }、5)。あなたのクリックリスナーの中に。 –

+0

「1つの方法の2つの機能」は意味をなさない。 'メソッド' **は ''関数 ''です。 –

答えて

0

int Delay_time_of_animation = 500;

btn.setOnClickListener(新View.OnClickListener(){ ます。public void onClickの(ビューのarg0){

Animation anim4 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.splash_anim); 
      btn.startAnimation(anim4); 

new Handler().postDelayed(new Runnable() { 
         @Override 
         public void run() { 

          startActivity(new Intent(MainActivity.this, splashActivity.class)); 
         } 
        }, Delay_time_of_animation); 

    } 
    }); 
0

私は遅延のためのネイティブJavaタイマーを使用しています。あなたは、2つの方法の間で遅延する場合あなたは2000

int DELAY_TIME=2000 

    //start your animation 
    new Timer().schedule(new TimerTask() {   
     @Override 
     public void run() { 
    //this code will run after the delay time which is 2 seconds. 
     startActivity(new Intent(MainActivity.this, splashActivity.class)); 
     } 
    }, DELAY_TIME); 

。ミリ秒単位で遅延時間を渡す必要がミリ秒は2秒を意味し、あなたが

関連する問題