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