2013-02-01 112 views
0

當用戶想要退出時,會彈出一個對話框,確定後,遊戲將退出。我的代碼不會調用另一個類。調用另一個班級失敗

private void giveup(){ 
    Context mcontext=this;  
    final AlertDialog.Builder alert = new AlertDialog.Builder(
        mcontext); 

    alert.setTitle("Are you sure to give up?"); 
    alert.setNegativeButton("Cancel", 
     new DialogInterface.OnClickListener() { 
       @Override 
       public void onClick(DialogInterface dialog, 
        int which) { 
        click.start(); 
        dialog.cancel();            

       } }); 
     alert.setPositiveButton("OK", 
       new DialogInterface.OnClickListener() { 
        @Override 
        public void onClick(DialogInterface dialog, 
          int which) { 
         click.start();           
         dialog.cancel(); 
         try{ 
          Class<?> ourClass = Class.forName("com.ithinkDictionary.Gameover"); 
          Intent ourIntent = new Intent(Playing.this, ourClass); 
          startActivity(ourIntent); 
         }catch(ClassNotFoundException e){ 
          e.printStackTrace(); 
        } 
       } 
     }); 
     alert.show(); 
    } 
}   
+0

你可以發佈你的日誌貓日誌 –

回答

3

你應該只使用

Intent ourIntent = new Intent(Playing.this, Gameover.class); 
          startActivity(ourIntent); 

假設既喜歡和GAMEOVER的活動。

相關問題