2017-06-22 4 views
-4

"startActivity(i);"にエラーが表示されます。startActivity(i);エラー

Error: startActivity (android.content.Intent) in Activity cannot be applied.

は、ここでは、コードです:

public class LoadingScreen extends Activity { 

    private static int SplashInterval = 2000; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.loading_screen); 

     new Handler().postDelayed(new Runnable(){ 
      @Override 
      public void run(){ 
       //TODO Auto-generated method stub 
       Intent i = new Intent(LoadingScreen.this, MainActivity.class); 
       startActivity(i); 
       finish(); 
      } 

     },SplashInterval); 
    }; 
} 
+0

私はあなたが質問をするのを忘れたと思う:p – Nathan

+0

貼り付けLoadingScreen.this.finish(); this.finish()の代わりに。 –

答えて

0

はこれを試してみてください

むしろ、この活動の閉鎖を達成するために LoadingScreen.this.finish(); を行うハンドラ

の内側に書かれている

0

削除この行をこの

new Handler().postDelayed(new Runnable() { 

     /* 
     * Showing splash screen with a timer. This will be useful when you 
     * want to show case your app logo/company 
     */ 

     @Override 
     public void run() { 
      Intent i = new Intent(LoadingScreen.this, MainActivity.class); 
      startActivity(i); 
      finish(); 

      // close this activity 
     } 
    }, SplashInterval); 
0

を試し、

public class LoadingScreen extends AppCompatActivity { 

    private static int SplashInterval = 2000; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.loading_screen); 

     new Handler().postDelayed(new Runnable(){ 
      @Override 
      public void run(){ 
       //TODO Auto-generated method stub 
       Intent i = new Intent(LoadingScreen.this, MainActivity.class); 
       startActivity(i); 

       this.finish(); 
      } 
      private void finish(){ 
       //TODO Auto-generated method stub 
      } 
     },SplashInterval); 
    }; 
} 
関連する問題