I'm making a small game using Android studio wich have 3 activities : Menu , Main(Game) , WinScreen . (我正在使用Android studio进行小型游戏,共有3个活动:Menu,Main(Game),WinScreen。) When I try to go from Menu to Main or WinScreen to Main it works perfectly fine but when I try to launch an activity from the Main activity I get an error. (当我尝试从菜单转到主菜单,或从WinScreen转到主菜单时,它工作正常,但是当我尝试从Main活动启动活动时,出现错误。)
I have a method in a java file that checks if the player won and if that's the case it is supposed to launch the WinScreen activity. (我在java文件中有一个方法可以检查播放器是否获胜,是否应该启动WinScreen活动。)
boolean checkWin(GameBoard gameboard){
if(compareTabs(gameboard) == true){
System.out.println("Win !");
Intent i = new Intent(MainActivity.this,WinActivity.class);
startActivity(i);
return true;
}
else{
return false;
}
}
And this is the error I get : error: not an enclosing class: MainActivity (这是我得到的错误: 错误:不是封闭的类:MainActivity)
This method is located in a file called GameBoard , GameBoard is used by the GameView Class who is launched at the start of the MainActivity (此方法位于一个名为GameBoard的文件中,该GameBoard由在MainActivity开头启动的GameView类使用。)
I know there is hundreds of posts similar to mine but I've pretty much tried everything I've found already and nothing seems to work and I'm pretty sure it's a really dumb issue . (我知道有数百篇与我相似的帖子,但是我已经尝试了很多我已经找到的所有内容,而且似乎没有任何效果,我敢肯定这是一个非常愚蠢的问题。)
I've already tried things like Intent i = new Intent(this,WinActivity.class);
(我已经尝试过Intent i = new Intent(this,WinActivity.class);
)