创建一个错误一个新的意向结果
问题描述:
当我这样做的休耕我得到的尖叫:
when i do the fallowing i get screamed on :
Button newGameButton = (Button) this.findViewById(R.id.newGameButton);
newGameButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
startActivity(new Intent(this,gameScreen.class));
}
});
显然我这是不是需要一
如何解决这个ERR?
apparently my this is not the one needed how can i fix this err?
答
我认为这个问题是在你的onClick活动范围界定问题,你这一点。在这种情况下这是指的onClick方法不是你的活动。尝试改变这样:
I think the problem is a scoping issue with your this in your onClick activity. In that instance this is referring to the onClick method not your Activity. Try changing it to this:
startActivity(new Intent(countryCityGameMenu.this,GameScreen.class));
这应该调整你的范围界定问题。
That should adjust your scoping issue.