Android 完成错误
刚开始一些基本的 Android 开发,我制作了一个带有 3 个按钮的小菜单。
其中之一是退出按钮(我知道完成活动并没有真正退出应用程序),但是当我调用它时,它会关闭应用程序并给我一个错误,指出应用程序已意外停止。
我的代码:
package darksea.game;
import android.app.Activity;
import android.os.Bundle;
public class DarkSeaActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void ExitGameEvent()
{
finish();
}
}
ExitGameEvent 通过 xml 链接到按钮。
有想过为什么会出现这个错误吗?
Just started with some basic android development and I made a little menu with 3 buttons.
One of them is a quit button (I know that the finish activity doesn't really quit the application) but when I call it it closes the application and gives me a error saying that the application has stopped unexpectedly.
My code :
package darksea.game;
import android.app.Activity;
import android.os.Bundle;
public class DarkSeaActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void ExitGameEvent()
{
finish();
}
}
The ExitGameEvent is linked to the button through xml.
Any thought on why it gives this error ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的点击处理程序需要获取视图< /a> 作为从 XML 调用它的参数。尝试:
Your click handler needs to take a View as an argument for it to be valid to be called from XML. Try: