[英]Err: constructor intent undefined
我收到此错误消息:令牌上的语法错误
这是我的代码:
package com.BartH.klok;
import android.app.Activity;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
public class help extends Activity {
Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
addListenerOnButton();
}
public void addListenerOnButton() {
button = (Button) findViewById(R.id.buttonback);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent5 = new Intent(this, Fullscreen.class);
startActivity(intent5);
}
});
}
}
基本上,我只想在按“ buttonback”后返回到“全屏”活动。 但是按钮对我来说是新的,所以我不确定如何执行此操作。 这是我得到的唯一错误。
感谢您的关注
this
是指当前对象,在本例中为OnClickListener,而不是Activity。 采用:
Intent intent5 = new Intent(help.this, Fullscreen.class);
另外,请阅读有关Java命名约定的信息 ,该约定规定类应以大写字母(CamelCase)开头。 因此,您的活动应命名为Help
。
它应该是:
Intent intent5 = new Intent(help.this, Fullscreen.class);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.