我是 Android 编程新手。我一直在使用 eclipse 并尝试开发一个两人井字棋游戏,但是每当玩家获胜时该应用程序就会崩溃。我尝试打开一个新活动 - 一个对话框显示玩家 x 获胜,两个按钮显示再次播放或退出。PlayerOne 和 PlayerTwo 类只是将内容视图设置为对话框。我尝试在 startActivity 方法周围放置 try 和 catch,但没有任何反应,我连续得到三个 X 或 O,游戏只是继续运行,没有显示任何对话框。那么有人可以帮助我吗?这是我的代码:
package com.rohan.tictactoe;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Main extends Activity implements OnClickListener{
Button t1,t2,t3,t4,t5,t6,t7,t8,t9;
int turn = 1;
int status = 0;
String s1,s2,s3,s4,s5,s6,s7,s8,s9 = "";
Intent i = new Intent("com.rohan.tictactoe.PlayerOne");
Intent x = new Intent("com.rohan.tictactoe.PlayerTwo");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initiallize();
}
@Override
public void …
Run Code Online (Sandbox Code Playgroud)