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();
}
}
你可以發佈你的日誌貓日誌 –