2011-02-08 2 views
1

이해하기 쉽도록하겠습니다.Android : SplashScreen 계속로드 중 아니요 내가하는 일

예를 들어 "Page1"과 "Page2"및 "Page3"이 있습니다. 확인. 나는 "Page2"에 스플래시 화면을 만들었고 사용자는 특정 시간 (5 초) 동안 "Page2"를 볼 수 있습니다. 자동으로 그에게 "Page3"을 지시하고 "Page2"에 두 개의 버튼을 추가하여 사용자가 "Page3"로 빠르게가는 "Button1"을 클릭 할 수 있습니다. 또는 "Button1"로가는 "Button2" 그래, 다 잘 됐어. 그러나 "Page2"가 켜져 있고 사용자가 아무 것도 건드리지 않으면 "Page3"로 이동합니다. 내 문제는 사용자가 "Button1"또는 "Button2"를 터치하여 "Page3"로 안내 할 수 있다는 것입니다. "Button2를"을 접촉하고 "페이지 1"이 "페이지 2"에되는 SplashScreen의 timelimit을가 된 후, 자동 "페이지 1"에서 "페이지 3"에서 그를 지시 (

이 제발 도와주세요 간다.

내 코드

인가
import android.app.Activity; 
import android.os.Bundle; 
import android.os.Handler; 
import android.view.View; 
import android.content.Intent; 
import android.view.View.OnClickListener; 
import android.widget.Button; 



public class StartGame extends Activity { 

    // =========================================================== 
    // Fields 
    // =========================================================== 

    private final int SPLASH_DISPLAY_LENGHT = 3000; 

    // =========================================================== 
    // "Constructors" 
    // =========================================================== 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle icicle) { 
     super.onCreate(icicle); 
     setContentView(R.layout.startgame); 

     /* New Handler to start the Menu-Activity 
     * and close this Splash-Screen after some seconds.*/ 
     new Handler().postDelayed(new Runnable(){ 
      @Override 
      public void run() { 
       /* Create an Intent that will start the Menu-Activity. */ 
       Intent mainIntent = new Intent(StartGame.this,Fail.class); 
       StartGame.this.startActivity(mainIntent); 
       StartGame.this.finish(); 
      } 
     }, SPLASH_DISPLAY_LENGHT); 

제발 도와주세요, 감사합니다. 와히드

EDIT :

미안하지만 초보자이고 변수를 만드는 법을 모르겠습니다. 나와 지식을 공유하고 소스 코드를 보여줄 수 있다면 제발.

변수는 버튼을 의미합니다. 즉 거기에 이미하지만 난 당신의 활동이이 버튼을 클릭하여 중지 된 경우는 postDelayed 호출을 취소 할 필요가 없습니다

답변

3

했다.

먼저 실행 파일과 처리기에서 변수를 만들어야합니다.

다음 중 버튼을 눌러에 당신이 전화를 할 수 있습니다 : 그것은 더 이상에 가정하지 않은 경우 트리거에서 중지됩니다

myHandler.removeCallbacks(myRunnable); 

.

myRunnable = new Runnable(){ 
     @Override 
     public void run() { 
      /* Create an Intent that will start the Menu-Activity. */ 
      Intent mainIntent = new Intent(StartGame.this,Fail.class); 
      StartGame.this.startActivity(mainIntent); 
      StartGame.this.finish(); 
     } 
    } 

    myHandler = new Handler(); 
    myHandler.postDelayed(myRunnable, SPLASH_DISPLAY_LENGHT); 
: 영업의 초보자 프로파일에 맞게

편집

관련 문제