public class androStrategy extends Activity implements OnClickListener
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Set up click listeners for all the buttons
View game_start = findViewById(R.id.btn_startGame);
game_start.setOnClickListener(this);
View save_exit = findViewById(R.id.btn_SaveExit);
save_exit.setOnClickListener(this);
View aboutButton = findViewById(R.id.btn_Help);
aboutButton.setOnClickListener(this);
}
// ...
public void onClick(View v)
{
switch (v.getId())
{
case R.id.btn_Help:
Intent helpIntent = new Intent(this, about.class);
startActivity(helpIntent);
break;
// More buttons go here (if any) ...
case R.id.btn_startGame:
Intent gameIntent = new Intent (this, Game.class);
startActivity(gameIntent);
break;
case R.id.btn_SaveExit:
finish();
break;
}
}
@Override
public void onPause()
{
super.onPause();
}
@Override
public void onResume()
{
super.onResume();
}
}
爲什麼代碼停止工作? 它工作過,我沒有在這裏改變ANYTHYNG。 我試過評論 意圖gameIntent = new Intent(this,Game.class); startActivity(gameIntent); 看看這是否會工作,而不是。主要活動部隊關閉
那麼我厭倦了Java的隨機錯誤。 現在它工作後,我喝咖啡它does not。
你可以發佈你的LogCat錯誤輸出嗎? –
我希望你使用的是LogCat,如果是的話,發佈你所得到的異常。 – whirlwin
代碼不會隨機破解(除非您有隨機數字執行關鍵任務)。什麼是堆棧跟蹤? – Haphazard