Reputation: 29
I got this error message: Syntax error on token
This is the code I have:
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);
}
});
}
}
Basically I just want to go back to the activity 'fullscreen' after the press of 'buttonback'. But the buttons are new from me so im not sure how to do this. This is the only error i get.
thanks for looking
Upvotes: 0
Views: 178
Reputation: 2748
It should be:
Intent intent5 = new Intent(help.this, Fullscreen.class);
Upvotes: 1
Reputation: 86948
this
refers to the current object, in this case the OnClickListener, not your Activity. Use:
Intent intent5 = new Intent(help.this, Fullscreen.class);
Also please read about Java naming conventions which state that Classes should start with an uppercase letter (CamelCase). So your Activity should be named Help
.
Upvotes: 2