创建一个错误一个新的意向结果 [英] Creating a new Intent results in a error

查看:312
本文介绍了创建一个错误一个新的意向结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我这样做的休耕我得到的尖叫:

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.

这篇关于创建一个错误一个新的意向结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆